#Chrome, FF, and Node agree on a regexp result I can't understand
11 messages · Page 1 of 1 (latest)
> '\nabcd'.match(/.{1,2}/g)
[ 'ab', 'cd' ]
> '\rabcd'.match(/.{1,2}/g)
[ 'ab', 'cd' ]
> '\tabcd'.match(/.{1,2}/g)
[ '\ta', 'bc', 'd' ]
newline and return are stripped, but tab isn't?
Regex without the s flag the dot doesn't match newline - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/dotAll
if you want an "any character" token without dotall, use [^]
it's an exclusive set that doesn't exclude anything
try https://regex101.com for testing/debugging regexes, there's a panel that explains each token
its so you can match multiple lines at a time without . overflowing thru lines
i guess it makes sense. however it also shows how weak a lot of my test cases have been
It isn't just JS either - Grep/ripgrep/VSCode search (which is just ripgrep under the hood) do a similar thing