regular expression for words code example
Example: 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