in reply to conditional expression testing
beri beri ^, then '(hana)' fails. Fail.
hana bbs ^(hana) (bbs), then '\2' fails. Backtrack; ^(hana)\2, then '\1' fails. Fail.
(?(1)...) doesn't make any sense since it's impossible to match the regex without the first capture matching something. Did you mean (?(2)...)?
'beriberi' =~ m#^(beri)(bbs)?(?(2)\2\1|\1)$#;
beri beri ^(beri)(bbs)?\1 $ Match.
'beribbsbbsberi' =~ m#^(beri)(bbs)?(?(2)\2\1|\1)$#;
beri bbs bbsberi ^(beri)(bbs)?\2 \1 $ Match.
Update: Added working examples
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: conditional expression testing
by Anonymous Monk on Jun 01, 2010 at 16:35 UTC | |
by ikegami (Patriarch) on Jun 01, 2010 at 16:51 UTC |