The answer depends on your consideration of the characters associated with the word cookie . If the word should appear strictly on one line, then:
var patt1=new RegExp(/^(biscuit|cookie)$/i);
If you want to allow characters (spaces, . ,, Etc.) but not alphanumeric values, try something like:
var patt1=new RegExp(/(?:^|[^\w])(biscuit|cookie)(?:[^\w]|$)/i);
The second regular expression is explained:
(?: # non-matching group ^ # beginning-of-string | [^\w] # OR, non-alphanumeric characters ) (biscuit|cookie) # match desired text/words (?: # non-matching group [^\w] # non-alphanumeric characters | $ # OR, end-of-string )
newfurniturey
source share