in reply to Regex help
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex help
by snacktime (Sexton) on Jun 02, 2005 at 17:54 UTC | |
by ikegami (Patriarch) on Jun 02, 2005 at 18:11 UTC |