in reply to Regular Expression match too much

m/\b$criteria\b/ - require a word break at each end of the text. Allows matches on 'SM and other stuff' or 'SM NP', but not on 'SMNP'.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Regular Expression match too much
by ikegami (Patriarch) on Feb 08, 2006 at 20:08 UTC

    Nice tip, but that should be m/\b(?:$criteria)\b/.

    print('BOTTOM' =~ m/\b$criteria\b/ ?1:0, "\n"); # 1 print('BOTTOM' =~ m/\b(?:$criteria)\b/ ?1:0, "\n"); # 0

      Hmm, sneeky. I come here to learn, I learned :). Thankyou.


      DWIM is Perl's answer to Gödel