Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named backrefs in conditional expressions behave differently #73

Open
k-takata opened this issue Nov 17, 2016 · 0 comments
Open

Named backrefs in conditional expressions behave differently #73

k-takata opened this issue Nov 17, 2016 · 0 comments

Comments

@k-takata
Copy link
Owner

k-takata commented Nov 17, 2016

Named backrefs in conditional expressions ((?(<name>)yes|no)) behave differently from normal named backrefs (\k<name>) in Ruby syntax.
\k<name> checks the last group with the name, if not matched then the previous one, and so on, until there is a match. (

Onigmo/doc/RE

Lines 321 to 323 in b334081

When backreferencing with a name that is assigned to more than one groups,
the last group with the name is checked first, if not matched then the
previous one with the name, and so on, until there is a match.
)
However (?(<name>)yes|no) only checks the left most group with the name. This behavior of the conditional expressions is the same as Perl, but inconsistent for Ruby.
The same strategy with \k<name> should be used for Ruby syntax.

Related: #74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant