Backport #8583
closed
A problem of condition regexp with a named capture
Added by ohai (Ippei Obayashi) over 11 years ago.
Updated over 11 years ago.
Description
以下の条件分岐を含む正規表現は "xy" "yx" にマッチし、"xx" "yy" にはマッチしません。
/\A((x)|(y))(?(2)y|x)\z/
名前付きキャプチャを用いた以下の正規表現も同じ挙動をするはずですが、そうはなっていません。
/\A((?x)|(?y))(?()y|x)\z/
"xx" "yy" にマッチして "xy" "yx" にはマッチしない。¶
2.0.0-p247, trunk の両方で確認しました。
この問題について調べた所、 名前付きキャプチャを使うときキャプチャの番号をrenumberしている
所で renumber がもれています。
添付したパッチのように修正すれば直ると思います。
Files
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: UNKNOWN, 2.0.0: REQUIRED
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: REQUIRED
Onigmo 5.13.5 has been released, which includes the fix.
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport200
- Target version deleted (
2.1.0)
- Status changed from Open to Assigned
- Assignee set to nagachika (Tomoyuki Chikanaga)
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r41780.
Ippei, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) 41764,41765,41767: [Backport #8583]
* regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161.
https://bugs.ruby-lang.org/issues/8583
* [bug] (thanks Akinori MUSHA and Ippei Obayashi)
Fix a renumbering bug in condition regexp with a named
capture. [Bug #8583]
* [spec] (thanks Akinori MUSHA)
Allow ENCLOSE_OPTION in look-behind.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0