in reply to Re^2: matching and mysterious captures
in thread matching and mysterious captures
which cleans out blank lines but keeps the spaces before three, you can use a non-capturing group (?:...) combined with the ? quantifier to make the whitespace matching conditional:zero <begin block> one two <end block> three
echo -e 'zero\none\ntwo three' | perl -0777 -wpe 's{\s*(one\ntwo)(?:\s*^)?( *)}{\n\n<begin block>\n\n$1\n\n<end block>\n\n$2}m'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: matching and mysterious captures
by Allasso (Monk) on May 05, 2011 at 18:51 UTC |