Apparently this pattern works in MRI 1.8.6, but not in MRI trunk or
JRuby 1.1.4. Should JRuby behave like MRI 1.8.6?
$ cat regex.rb
puts “a” =~ /(.)\Z?/
$ ruby -v regex.rb
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
0
$ ruby19 -v regex.rb
ruby 1.9.0 (2008-09-21 revision 17753) [i386-darwin9.5.0]
regex.rb:1: target of repeat operator is invalid: /(.)\Z?/
$ jruby -v regex.rb
jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-08-28 rev 7570) [i386-
java]
regex.rb:1: target of repeat operator is invalid: /(.)\Z?/ (RegexpError)
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
This is one of very few Oniguruma and 1.8.6 regexp engine
incompatibilities and it has already been filed for JRuby and Rubnius:
http://jira.codehaus.org/browse/JRUBY-2780
http://rubinius.lighthouseapp.com/projects/5089-rubinius/tickets/587-regexperror-target-of-repeat-operator-is-invalid
Allowing quantifier application to anchors alone won’t solve
compatibility problem entirely, although this will work:
“a” =~ /(.)\Z?/
this example would fail:
“a” =~ /(z)\Z?/
I think we should address this problem on ruby-core since whether the
issue will show up for 1.9 is just a matter of time. I have a few ideas
how to achieve this compatibility but don’t want to reinvent the wheel
in case somebody else was considering that already.
Latest Oniguruma in Ruby 1.9 trunk, version (5.9.1) has undergone huge
modifications whereas Rubinius uses vanilla one. We try to keep JOni up
to date with 1.9 changes (plus allowing vanilla mode).
Marcin
Hirotsugu A. pisze:
regex.rb:1: target of repeat operator is invalid: /(.)\Z?/
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email