Regular expression quirk?

A

Ammar Ali

Hello,

AFAIK, there are no possessive quantifiers in 1.9, so I expected a
syntax error from this:
=> /cats?+/

It worked and it works, but the + is meaningless it seems:
=> #<MatchData "cats">

Interestingly, the + is "preserved":
=> "cats?+"

Does this make sense to anyone?

Thanks,
Ammar
 
R

Robert Klemme

One more thing, Read Ruby
(http://ruby.runpaint.org/regexps#quantifiers) doesn't even mention
possessive quantifiers. Hmmm.

Not everything in Oniguruma is supported in ruby. I guess I need to
verify this further.

irb(main):001:0> /a+a/ =3D~ "aaa"
=3D> 0
irb(main):002:0> /a++a/ =3D~ "aaa"
=3D> nil

What else do you need to verify?

Cheers

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
A

Ammar Ali

On Wed, Oct 27, 2010 at 1:47 PM, Robert Klemme
irb(main):001:0> /a+a/ =3D~ "aaa"
=3D> 0
irb(main):002:0> /a++a/ =3D~ "aaa"
=3D> nil

What else do you need to verify?

I ran similar tests and they work as expected from possessives, so I'm
sure they are supported. I would like to see it clearly stated in ruby
documentation. I logged an issue about it for Read Ruby
http://github.com/runpaint/read-ruby/issues#issue/74

Thanks again,
Ammar
 

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

Forum statistics

Threads
473,812
Messages
2,569,694
Members
45,478
Latest member
dontilydondon

Latest Threads

Top