J
John Halderman
------=_Part_843_19167012.1122060553053
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I'm not sure if this is a bug or intentional behavior, so I thought I would=
=20
post it here to see what the community thought of what was happening. If yo=
u=20
set up a StringScanner object to perform iterative matching on a string the=
=20
behavior of \A and ^ seem to always match. It seems to me that \A should=20
only match if it is the first match performed, and ^ should only match if=
=20
bol? returns true, which should be after a \n or if it is the first match=
=20
performed. Here is some code I ran in irb to illustrate the problem:
require 'strscan'
sc =3D StringScanner.new("the white elephant eats grass")
sc.scan(/the\s+/)
sc.bol?
sc.scan(/^white\s+/)
sc.scan(/\Aelephant\s+/)
this code produced the following result.
irb(main):001:0> require 'strscan'
=3D> true
irb(main):002:0> sc =3D StringScanner.new("the white elephant eats grass")
=3D> #<StringScanner 0/29 @ "the w...">
irb(main):003:0> sc.scan(/the\s+/)
=3D> "the "
irb(main):004:0> sc.bol?
=3D> false
irb(main):005:0> sc.scan(/^white\s+/)
=3D> "white "
irb(main):006:0> sc.scan(/\Aelephant\s+/)
=3D> "elephant "
Any thoughts and or advice on this matter are greatly appreciated.
-John Halderman
------=_Part_843_19167012.1122060553053--
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I'm not sure if this is a bug or intentional behavior, so I thought I would=
=20
post it here to see what the community thought of what was happening. If yo=
u=20
set up a StringScanner object to perform iterative matching on a string the=
=20
behavior of \A and ^ seem to always match. It seems to me that \A should=20
only match if it is the first match performed, and ^ should only match if=
=20
bol? returns true, which should be after a \n or if it is the first match=
=20
performed. Here is some code I ran in irb to illustrate the problem:
require 'strscan'
sc =3D StringScanner.new("the white elephant eats grass")
sc.scan(/the\s+/)
sc.bol?
sc.scan(/^white\s+/)
sc.scan(/\Aelephant\s+/)
this code produced the following result.
irb(main):001:0> require 'strscan'
=3D> true
irb(main):002:0> sc =3D StringScanner.new("the white elephant eats grass")
=3D> #<StringScanner 0/29 @ "the w...">
irb(main):003:0> sc.scan(/the\s+/)
=3D> "the "
irb(main):004:0> sc.bol?
=3D> false
irb(main):005:0> sc.scan(/^white\s+/)
=3D> "white "
irb(main):006:0> sc.scan(/\Aelephant\s+/)
=3D> "elephant "
Any thoughts and or advice on this matter are greatly appreciated.
-John Halderman
------=_Part_843_19167012.1122060553053--