regex for words code example
Example 1: regex for entire word
/\b(word)\b/i
Example 2: regular expression for words and words with apostrophes
/(?:\w|['-]\w)+/
//matches: we, we're, were
//ignores: ' (lone apostrophe), (whitespace)
OPPOSITE: /\s+|[^'-\w]+|[0-9]+/
//matches: numbers, whitespace, punctuation (except in contractions/hiphenated words)
//ignores: words/contractions/hiphenated words