in reply to Regex to match text in broken parens
for (@test) { if (/ .* (^|\() (.*?) (\)|$) /x and my $p = "$1$3") { print ' Match ', { ')' => 'before right paren', '(' => 'after left paren', '()' => 'in parens', }->{$p}, ": $2\n"; } }
It's not clear, though, what should happen if the parentheses were nested.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex to match text in broken parens
by Rodster001 (Pilgrim) on Oct 31, 2014 at 19:25 UTC | |
by ww (Archbishop) on Oct 31, 2014 at 21:21 UTC |