$pattern = 'match'; @array = ('hello', 'matched', 'match', 123, 'sleep'); foreach (@array) { # Matched 'match' but not 'matched' print "$1\n" if /\b($pattern)\b/; #print "$1\n" if /(\b$pattern\b)/; }
Should I put the '\b' inside the brackets or outside them? Please advise and thanks in advance :)
Edited 2001-11-02 by Ovid
In reply to regular expression by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |