Shorthand notation for multiline in regexps?

Is there a way to declare a multiline or ignorecase regexp without using
Regexp.new()? I’d like to be able to do something like:

/someregexp/im

or something like that, similar to the way perl allows you to put stuff
after the regexp. I can’t find anything about this in Programming Ruby.

Carl Youngblood

Yes. /someregexp/im will do multiline and ignorecase.

-austin

···

On Thu, 9 Oct 2003 00:09:23 +0900, Carl Youngblood wrote:

Is there a way to declare a multiline or ignorecase regexp without using
Regexp.new()? I’d like to be able to do something like:

/someregexp/im

or something like that, similar to the way perl allows you to put stuff
after the regexp. I can’t find anything about this in Programming Ruby.


austin ziegler * austin@halostatue.ca * Toronto, ON, Canada
software designer * pragmatic programmer * 2003.10.08
* 11.22.00

“Carl Youngblood” carl@ycs.biz schrieb im Newsbeitrag
news:cLVgb.521546$Oz4.379040@rwcrnsc54…

Is there a way to declare a multiline or ignorecase regexp without using
Regexp.new()? I’d like to be able to do something like:

/someregexp/im

or something like that, similar to the way perl allows you to put stuff
after the regexp. I can’t find anything about this in Programming Ruby.

MY_LONG_COMMENTED_REGEXP = /
(\w+) # given name
\s+
(\w+) # surname
\s+
(\d+) # age
/mix

Reegards

robert

Austin Ziegler wrote:

or something like that, similar to the way perl allows you to put stuff
after the regexp. I can’t find anything about this in Programming Ruby.

http://www.rubycentral.com/book/language.html#UJ

···

Chris
http://clabs.org/blogki