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;
In reply to Re: How to replace on a smooth way?
by Ratazong
in thread How to replace on a smooth way?
by bestsiteeditor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |