matz / zetabits.com (Yukihiro Matsumoto) wrote:
>
>Hi,
>
>In message "[ruby-talk:10417] Recall Regexp options?"
>     on 01/02/06, "Ben Tilly" <ben_tilly / hotmail.com> writes:
>
>|Does this make sense to anyone?
>
>No.  I should have compare all option flags for equal test.
>I'll fix it soon.

Thank you, and if you make the options available as an
attribute of Ruby, I will be most grateful.

>|PPS Coming from Perl I find it disconcerting to see
>|Ruby's /m flag combine options that I am used to seeing
>|separately as /s and /m.
>
>In Perl, it is possible to specify /s and /m at the same time.  It
>probably is feature rich, but I find it disconcerting.

<ramble>

The naming is disconcerting, but they do unrelated
things.  /m affects what ^ means.  /s affects what .
means.  They affect them in opposite directions.

The default behaviour in Perl is that ^ acts like a
string is a single line, and . acts like returns are
not part of the string.  /s changes . to act like you
have a single string with embedded returns.  /m
changes ^ to act like you have multiple logical lines.

If you want to combine the options into one, the least
surprise for me would be to switch between /s and /m
behaviour, not / to /sm.  That is make . and ^ both
agree on whether the string has one or many lines in
it.  OTOH that will make the default behaviour of Ruby
different than the defaults of most other languages,
surprising people again.

I suspect the *minimum* surprise would be to by default
act like Perl's /m - so . does not match \n and ^ will
match at the beginning of a line.  (Thereby making
Ruby act a lot like standard Unix utilities.)  Then have
a /s option.  But that would probably break a lot of
code. :-(

</ramble>

I don't know that there is a good answer...  But Perl's
answer is the one I am used to.

Cheers,
Ben
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com