in reply to How to find the outermost pair of square brackets with a regex?
Surely this will do it:
$str = ' blah blah blah blah blah blah blah blah [blah [blah blah] [blah blah blah blah] blah] blah blah'; $str =~ m/\[(.*)\]/s; print $1;
Because the regex finds the leftmost pattern, /s allows dot to match linebreaks and dot-star is greedy, that's all you need. Am I missing something?
($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to find the outermost pair of square brackets with a regex?
by lokiloki (Beadle) on Jan 17, 2007 at 07:15 UTC | |
by ikegami (Patriarch) on Jan 17, 2007 at 16:25 UTC | |
by lokiloki (Beadle) on Jan 17, 2007 at 20:35 UTC | |
by ikegami (Patriarch) on Jan 17, 2007 at 20:43 UTC | |
by lokiloki (Beadle) on Jan 17, 2007 at 07:23 UTC |