[rcr] supply option hash to Regexp.new

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

···


Simon Strandgaard

+1

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:20040602230945.768b8989.neoneye@adslhome.dk…

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

···


Simon Strandgaard

Robert Klemme wrote:

+1

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:20040602230945.768b8989.neoneye@adslhome.dk…

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

Robert, +1 ?? if we calculate the flags for ‘uxim’

then ‘u’ => 64, ‘x’ => 2, ‘i’ => 1, ‘m’ => 4 … sum=71

···

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


Simon Strandgaard

Hi –

···

On Thu, 3 Jun 2004, Simon Strandgaard wrote:

Robert Klemme wrote:

+1

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:20040602230945.768b8989.neoneye@adslhome.dk…

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

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” :slight_smile:

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

David


David A. Black
dblack@wobblini.net

David A. Black wrote:

···

On Thu, 3 Jun 2004, Simon Strandgaard wrote:

Robert Klemme wrote:

+1

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:20040602230945.768b8989.neoneye@adslhome.dk…

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

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” :slight_smile:

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.


Simon Strandgaard

[snip]

I better fill in an rcr for this.

I have added an RCR entry… vote on it here :slight_smile:

http://rcrchive.net/rcr/RCR/RCR258

···

Simon Strandgaard neoneye@adslhome.dk wrote:


Simon Strandgaard

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:20040603002341.48b0e0aa.neoneye@adslhome.dk…

David A. Black wrote:

Robert Klemme wrote:

+1

“Simon Strandgaard” neoneye@adslhome.dk schrieb im Newsbeitrag
news:20040602230945.768b8989.neoneye@adslhome.dk…

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

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” :slight_smile:

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

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
···

On Thu, 3 Jun 2004, Simon Strandgaard wrote: