IMO it would be nice to support the ability to use whitespace to aid readability, an example from the proposal:
let regex = #/
# Match a line of the format e.g "DEBIT 03/03/2022 Totally Legit Shell Corp $2,000,000.00"
(?<kind> \w+) \s\s+
(?<date> \S+) \s\s+
(?<account> (?: (?!\s\s) . )+) \s\s+ # Note that account names may contain spaces.
(?<amount> .*)
/#
That being said, I do agree that the following is surprising:
At the very least, if this is the behavior we decide to go with, it seems like we could warn when whitespace is intermixed between literal characters in a regex. For example a b c
would raise a warning, but \d \s | [abc]
would not. I'm not sure whether we'd want the warning to apply to a character class such as [ a b c ]
though (maybe only if there's a single space?).