in reply to spaces removed in backreference
Or like this, using captures (possibly a little bit "less efficient", but not enough to worry about it):s/(?<=>) +(?=<)//g;
(No need to "loop until done" -- the "g" modifier takes care of the whole string.)s/(>) +(<)/$1$2/g;
I also wonder why you use backslashes instead of dollar signs for your captures in the replacement part. If you had use warnings; in your code, you would have been told: "\1 better written as $1..." (and I suspect there's a good reason why, but it escapes me at the moment).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: spaces removed in backreference
by Allasso (Monk) on Apr 25, 2010 at 09:49 UTC |