Bug #9728
closed
Added by sawa (Tsuyoshi Sawada) about 10 years ago.
Updated over 9 years ago.
Description
As reported in StackOverflow (http://stackoverflow.com/questions/23004527) (with a wrong expectation), the following regex pattern with the *
operator does not match.
"ab" =~ /(?!^a).*b/
# => nil
When ?
is used instead, it seems to match correctly:
"ab" =~ /(?!^a).?b/
# => 1
According to the original reporter of the linked site, this does not happen in Ruby 1.9.3.
I found this issue is related with the ONIG_DONT_OPTIMIZE macro.
If I insert "#define ONIG_DONT_OPTIMIZE" in regint.h, the regexp works like Ruby 1.9.3.
before define:
C:\work\ruby-2.2.0-r45349>miniruby -ve 'p "ab"=~/(?!^a).*b/;'
ruby 2.2.0dev (2014-03-16 trunk 45349) [x64-mswin64_120]
nil
after define:
C:\work\ruby-2.2.0-r45349>miniruby -ve 'p "ab"=~/(?!^a).*b/;'
ruby 2.2.0dev (2014-03-16 trunk 45349) [x64-mswin64_120]
1
- Status changed from Open to Closed
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED
- Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE
partially backport r47598 into ruby_2_1
branch at r47954.
- Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE
Backported into ruby_2_0_0
at r47976.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0