I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Anything that's parsable data should be parsed with a parser. that makes sense.
But regular expressions don't need to be complicated just because they're complex; you can write them across several lines and add named groups and comments to every part. That's probably easier to maintain than a great list of individual conditions, like, if (string.startsWith('foo') && string.endsWith('bar')) { and so on.
Writing regular expressions is an art for sure. I’ve seen ones that are written extremely well (multiple lines, named capture groups, etc) but it doesn’t help if the input schema is always changing and requiring the regular expression to be re-written.
I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
Anything that's parsable data should be parsed with a parser. that makes sense.
But regular expressions don't need to be complicated just because they're complex; you can write them across several lines and add named groups and comments to every part. That's probably easier to maintain than a great list of individual conditions, like,
if (string.startsWith('foo') && string.endsWith('bar')) {
and so on.Writing regular expressions is an art for sure. I’ve seen ones that are written extremely well (multiple lines, named capture groups, etc) but it doesn’t help if the input schema is always changing and requiring the regular expression to be re-written.
If that's the case, then nothing helps!