When you use regex, be sure to use just enough abstraction that you can swap out the regex implementation with a parser later on.
There are three main traps with regex:
Regex do not handle recursive structures.
Regex do not handle irregular languages.
Regex scale rapidly to become impossible for a human to understand.
It is quite difficult to predict when you'll hit one of these limits, so a little abstraction goes a long way.
Instead of putting regex directly in your code, abstract them with a procedure that does something: e.g., getName(foo) instead of (foo.match(/([^/]+)/) || [])[1]; :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Regex can be useful, but can also be a trap.
When you use regex, be sure to use just enough abstraction that you can swap out the regex implementation with a parser later on.
There are three main traps with regex:
It is quite difficult to predict when you'll hit one of these limits, so a little abstraction goes a long way.
Instead of putting regex directly in your code, abstract them with a procedure that does something: e.g., getName(foo) instead of (foo.match(/([^/]+)/) || [])[1]; :)