Robert Feldt
3/21/2006 1:09:00 PM
On 3/21/06, Carlos <angus@quovadis.com.ar> wrote:
> Robert Feldt wrote:
> > Hi,
> >
> > I've been bitten by this discrepancy on some occasions:
> >
> > irb(main):003:0> StringScanner.new("").match?(/\s*/)
> > => nil
> > irb(main):004:0> /\s*/ =~ ""
> > => 0
> >
> > Running: ruby 1.8.4 (2005-12-24) [i686-linux]
> >
> > Is it a bug or a feature?! I can see arguments for both sides but for
> > me it violates POLS. Opinions?
>
> I think, if it matches /\s*/ at end of string, then it should scan it
> too; and then, #eos? would never be true (you could scan /\s*/ at the
> end infinitly).
>
My point is that my POLS is that eos? should be true *and* you should
be able to scan any regexp that can match empty string infinitely at
the end. If not the behavior at the end is different than from within
which means that users need to handle the situation differently
depending on when such regexps are used.
But my POLS might be "wrong".
/R