in reply to Regex help
If I read the requirement of AM correct, he wants to check for the presence of a $symbol in a $sentence, where the beginning and end of $symbol should also be treated as word boundaries, provided they are word characters.
For this I would propose the following regex (using conditional pattern as suggested by japhy above):
if ($sentence =~ /(?(?=\w)(?:\b))$symbol(?(?<=\w)(?:\b))/) { # do something }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex help
by ysth (Canon) on Jan 15, 2006 at 09:34 UTC |