in reply to A regex question
for (@{$msg->body}){ s/\bblah\b/something/g; print; }
It does nearly the same thing as your original loop, but it has a slightly different notion of where a word ends.
If you really want whitespace delimited words you can change the regular expression to read
s/(?<=^| )blah(?= |$)/something/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A regex question
by johngg (Canon) on Jan 16, 2008 at 23:15 UTC |