Page 1 of 1

Macthing whole words and not substrings

Posted: Fri Jan 22, 2010 1:29 pm
by kendall
Hey guys I'm trying to write a regexp that will match a range of alternate whole words but not match substrings

for e.g.

Code: Select all

/cat|hat|sat/
would match
cat or sat
but not
catalyst or saturday

Re: Macthing whole words and not substrings

Posted: Fri Jan 22, 2010 1:41 pm
by Weirdan

Re: Macthing whole words and not substrings

Posted: Fri Jan 22, 2010 1:47 pm
by kendall
Weirdan wrote:http://www.regular-expressions.info/wordboundaries.html

Code: Select all

 
/\b(cat|hat|sat)\b/
 
aaahhh i see the \b at the end of the pattern...i only had it before the pattern thanks