# Help needed with Regexp Class

**URL:** <https://www.ruby-forum.com/t/help-needed-with-regexp-class/87670>\
**Category:** Ruby\
**Created:** [March 5, 2007, 2:17am UTC](https://www.ruby-forum.com/t/help-needed-with-regexp-class/87670 "2007-03-05T02:17:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [March 5, 2007, 2:17am UTC](https://www.ruby-forum.com/t/help-needed-with-regexp-class/87670/1 "2007-03-05T02:17:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [March 5, 2007, 2:39am UTC](https://www.ruby-forum.com/t/help-needed-with-regexp-class/87670/2 "2007-03-05T02:39:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [March 5, 2007, 2:46am UTC](https://www.ruby-forum.com/t/help-needed-with-regexp-class/87670/3 "2007-03-05T02:46:44Z")

</div>

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
