4 ms·
to your point (and how to fix it in a way that seemingly nobody does) - you can make complicated regular expressions pretty simple by using named groups, and ig
by viggity 5y ago
to your point (and how to fix it in a way that seemingly nobody does) - you can make complicated regular expressions pretty simple by using named groups, and ignoring pattern whitespace because they allow you to logically separate different components and specify intent. Nobody would ask a fellow dev to debug javascript where it is all on a single line and every variable name is a1, a2, etc. Except people do it all the time with regex. Its insane. Hell, you don't even get the blessing of a1, a2, a3. It is all unnamed. Insanity.
Some rare people can figure out:
\d{1,2}[-/]\d{1,2}[-/](\d{4}|\d{2})
but a dummy can figure out this:
(?<month>
\d{1,2}
)
[-/]
(?<day>
\d{1,2}
)
[-/]
(?<year>
\d{4}
|
\d{2}
)