http://www.perlmonks.org?node_id=109340


in reply to Re: Reg Expression Question
in thread Reg Expression Question

Did you try the code you suggested above? For output I get:

2 3 4 5 20 23 34
It incorrectly matches on 2,3 and 4. Now if you had modified your regex to be:
$okvalues =~ m/\b$i\b/
You wouldn't have that problem, because the \b assertion is only true between a word char and a non wordchar. This stops '3' from matching on '34'. Though, its still not a good idea to do it this way.

-Blake