Test, validate and match regular expressions
Extracts words from a sentence using Java named capture groups, matching three token types: contractions/possessives with apostrophes (ApWord like don't), hyphenated compounds (HyWord like well-known), and plain words (Rest). The alternation order ensures apostrophe/hyphen words are captured whole before the generic \w+ fallback splits them. With global and multiline flags, it's ideal for tokenizing text where punctuation-joined words must stay intact.