Hi,
In message "[ruby-talk:02027] Re: Ruby Syntax similar to other languages?"
on 00/03/20, David Suarez de Lis <excalibor / demasiado.com> writes:
|Good morning, (for me :)
Good morning, (for me :)
|> Hmm, although I think options i, s, m, o, and x should belong to
|> regexp, I can understand your opinion.
|
|Certainly, options should belong to the re... that would make it
|
|string.s(/regex/imx, "replacement" [, OVERWRITE])
Well, regexp options i, o, x are available now. There's no equivalent
for Perl's s, m, but p - posix match - for treating newlines as a
normal character.
|Even ``string =~ /regex/i'' looks unnatural... (even very familiar to sed, vi, Perl users)
|
|I'd rather reduce interfaces to ``string.m(/regex/i)'' which feels
|more like OO to me: apply the m(atch) method to object ``string''
|with this regex object ``/regex/'' with options ``i''
There's already Regexp#match. e.g.
/regexp/.match(str)
matz.