[ruby-core:77463] [Ruby trunk Bug#12728][Rejected] Negative lookahead does not work for "+" even though works for "@"
From:
naruse@...
Date:
2016-09-30 21:57:54 UTC
List:
ruby-core #77463
Issue #12728 has been updated by Yui NARUSE.
Status changed from Open to Rejected
In case 2, the regexp just behave as if
```
t %r{
(?<!\\)\( # outer bracket
o\+
(?<!\\) ([+*]|\{\d+,\}) (?!\+) # inner repetition, non possessive
.*
(?<!\\)\) # outer bracket
(?<!\\) (?:[+*]|\{\d+,\}) # unbounded repetition, non possessive
}x, "f(o++)+"
```
Of course it matches.
Maybe use should `[a-zA-Z0-9]*` or something instead of `.*`.
----------------------------------------
Bug #12728: Negative lookahead does not work for "+" even though works for "@"
https://bugs.ruby-lang.org/issues/12728#change-60734
* Author: Robert Klemme
* Status: Rejected
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-cygwin]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I'll attach a test program that shows the effect. Basically, if I have a negative lookahead in the regex like (?!@) and "@" shows up in the proper location I get a mismatch (1. case). This is expected. If I exchange the "@" with a "\+" or "[+]" in the regex and a "+" in the input, a match occurs (case 2 and 3). This is the bug. If the "+" or "@" is removed from the string an expected match occurs (case 4 and 5). I was not able to boil this down to a smaller example yet.
---Files--------------------------------
rx-mini.rb (1.63 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>