in reply to How to replace on a smooth way?
You search for a §, followed with anything but a blank and store it to $1. Then you replace it by itself surrounded by brackets. The modifier g means that you do it as often as possible. Update: Thanks to i5513 and MidLifeXis for their improvements of my regex and for polishing my rusty knowledge! I like that in PerlMonks: by answering questions you often learn something for yourself, too :-)$s =~ s/(§[\S]*)/\[$1\]/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to replace on a smooth way?
by MidLifeXis (Monsignor) on Apr 19, 2012 at 14:37 UTC | |
|
Re^2: How to replace on a smooth way?
by i5513 (Pilgrim) on Apr 19, 2012 at 14:25 UTC | |
|
Re^2: How to replace on a smooth way?
by bestsiteeditor (Initiate) on Apr 19, 2012 at 14:18 UTC | |
by MidLifeXis (Monsignor) on Apr 19, 2012 at 14:31 UTC | |
by roboticus (Chancellor) on Apr 19, 2012 at 14:33 UTC |