shorthand notation for multiline in regexps?

  • Thread starter Carl Youngblood
  • Start date
C

Carl Youngblood

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
 
R

Robert Klemme

Carl Youngblood said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,137
Messages
2,570,795
Members
47,342
Latest member
eixataze

Latest Threads

Top