[rcr] supply option hash to Regexp.new

  • Thread starter Simon Strandgaard
  • Start date
S

Simon Strandgaard

Regexp.new is old, and relies on C'ish magic values.

Lets write something ugly with the current initialize:
Regexp.new('a.*a', 5, 'U')
Thats the same as /a.*a/uxim

The problem is these legacy values
Regexp::IGNORECASE = 1
Regexp::EXTENDED = 2
Regexp::MULTILINE = 4

I propose to let initialize take a hash.

Regexp.new('a.*a', :ignorecase=>true, :extended=>true, :multiline=>true, :encoding=>:UTF8)


Ideas for other options: :interpret_warnings_as_errors, :verbose_mismatch
 
D

David A. Black

Hi --

Robert, +1 ??

I think +1 means "I vote yes" (or in this case perhaps, "I will vote
yes when the RCR is submitted on RCRchive" :)

I also like the idea of discarding these cryptic Regexp things.


David
 
S

Simon Strandgaard

David said:
I think +1 means "I vote yes" (or in this case perhaps, "I will vote
yes when the RCR is submitted on RCRchive" :)

I also like the idea of discarding these cryptic Regexp things.

ok.. apparently +1 translates into 'i vote yes'.. I guessed so.
Just wanted to point out my that the value 5 was sligthly wrong.
It should have been 7. 5+1 would only be 6 (halfway).

I better fill in an rcr for this.
 
R

Robert Klemme

Simon Strandgaard said:
ok.. apparently +1 translates into 'i vote yes'..
Right.

I guessed so.
Just wanted to point out my that the value 5 was sligthly wrong.
It should have been 7. 5+1 would only be 6 (halfway).

Halfway is often better than no progress at all. :))

Regards

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
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top