I’m building up a library of filters for a validation class in PHP, some of them using regular expressions. I have a lot of filters in mind, but I also don’t want to potentially miss any. What do you most often use regular expressions to check? What are some of the not-so-common things that you’ve had to check that would still be useful in a library? Note: I’m not looking for the actual regex code, just what you use it for.
Share
Regex should be strongly tested with their expected use cases. Hence, it may be difficult to develop a complete and general library. I would aim for a library of functions you know you need now. Then add to this list later, when you have proper test cases.
That said, here are some common use cases:
Numeric Data
Phone numbers
Dates
Zip codes
SSN