s///g won't search replaced text, as shown in the following snippet:
$search_for = '[string]'; $user = '[user]'; local $_ = 'foo [string] bar [string] baz'; s/(\Q$search_for\E)/__${user}__${1}__/g; print("$_\n"); # foo __[user]__[string]__ bar __[user]__[string]__ baz
You can use s///ge if you need to generate $user dynamically for each match.
In reply to Re: Regex help
by ikegami
in thread Regex help
by snacktime
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |