Forum: Ruby Help needed with Regexp Class

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sean S. (Guest)
on 2007-03-05 03:17
I can not seem to get the Regexp::MULTILINE mode enabled for specific
Regexp objects. I've tried:

Regexp.new(expr, 'm')
Regexp.new(expr, '/m')
Regexp.new(expr, Regexp::MULTILINE)

among others. What goes in the option field? Thanks in advance,

Sean
unknown (Guest)
on 2007-03-05 03:39
(Received via mailing list)
Hi --

On Mon, 5 Mar 2007, Sean Smitz wrote:

> I can not seem to get the Regexp::MULTILINE mode enabled for specific
> Regexp objects. I've tried:
>
> Regexp.new(expr, 'm')
> Regexp.new(expr, '/m')
> Regexp.new(expr, Regexp::MULTILINE)
>
> among others. What goes in the option field? Thanks in advance,

irb(main):001:0> Regexp.new(".", Regexp::MULTILINE)
=> /./m

If expr is itself a regex, then the multiline flag will be ignored,
but you should get a warning for that.


David
Sean S. (Guest)
on 2007-03-05 03:46
Nevermind, I just tried Regexp::MULTILINE in there and this time it
worked... How very annoying. Thank you

Sean

>
> irb(main):001:0> Regexp.new(".", Regexp::MULTILINE)
> => /./m
>
> If expr is itself a regex, then the multiline flag will be ignored,
> but you should get a warning for that.
>
>
> David
This topic is locked and can not be replied to.