Micro-post:
I was truly shocked to find today that in JavaScript regular expressions, . (the decimal point) doesn't do what I thought it did. I thought . meant "match any character." You too? Yeah. But it doesn't. Specifically, . doesn't match line terminators (so, \r, \n, \u2028, and \u2029). From Section 15.10.2.8:
The productionAtom :: .evaluates as follows:
- Let A be the set of all characters except LineTerminator.
- Call CharacterSetMatcher(A, false) and return its
Matcherresult.
...which if you spend really quite a long time looking tells you that . matches anything but line terminators.
Maybe I'm just parading my ignorance here, but I would have thought that absent the "multiline" flag or something, . matched everything. Nope. If you want to do that, use [\s\S] (e.g., everything that either is or isn't whitespace).
Happy coding!