This regular expression meets all of those security requirements set by the internet people.
Except for lengths. :D
Definitely.
I didn't take the time to battle test it, but when I read (\.[^<>()\[\]\\.,;:\s@"]+)*) in the sample above, I started to smell redos opportunities here
On that note, I recently discovered that some regex engines treat some meta characters differently depending on the locale. With Python (and it changed between 2 and 3!) \w is either equivalent to [a-zA-Z0-9_], or the same one plus all the diacritics of the language (e.g. éèàùç...) (in Python, that's where the re.ASCII flags is useful
I'm curious to see how people use regexes e.g. which one do you use between \d vs [0-9], things like that?
Well 90% of my regex use is searching through codebase or logfiles or the like. Not as part of the application, so I just use whatever works. For real text, I think you'd need \p{L} (src) but unicode is tricky...
Jason Knight
The less code you use, the less there is to break
Except for lengths. :D