3 ms·
Here, you have good advice: "I ... consider regex expressions as the wrong solution. They're notoriously hard to get right." However, the conclusion of "use so
by htek 2y ago
Here, you have good advice: "I ... consider regex expressions as the wrong solution. They're notoriously hard to get right."
However, the conclusion of "use something somebody else wrote that does it properly", while valid, is asking a lot. As regex is hard to get right, don't assume the code you find on the web or book or via some other means works correctly.
My rule is if I didn't write it and can't wrap my head around the code to convince myself it is the right solution, I don't use it. And as I think others have written, there are some interactive online tests for regex expressions that can help.
- cedws 2y agoI think the average developer has a better chance of finding a robust, battle tested library to do what they need than cooking up some regex of their own. Preferably, the library does not use regex at all and checks data more intelligently.