How do I validate regular expression patterns?

What are the general ways to validate a given regex pattern working well in a given scenario and validating the results?

I would like to know in general, not a specific programming language, and what is the best way to learn about writing a regex?

+2


source to share


6 answers




+4


source


I used this resource while learning: http://www.regular-expressions.info/ and found myself going back there when there is something I need to remember. This is very helpful for learning and describes the basics very well. They also have various links to programs that can be used to test regular expressions.



+3


source


This is not a "real" check, but RegexBuddy allows you to check that your regular expression does what you expect it to do on whatever sample data you provide. It also translates the regular expression into an English description, which can help you figure out errors. In addition, it knows all the basic regex variants and can translate regexes between them.

+3


source


To test the regular expression, you can use the RegEx testing tools as shown below:

To learn more about how to learn regular expressions check out the following SO threads:

0


source


RAD Rexexp designer is a great tool

0


source


Set up an automated test using the tools of your choice (since regex implementations vary from language to language and library to library) that applies the regex to many of both matched and inconsistent inputs to make sure you get the correct results.

While RegexBuddy and the like can be useful for initially creating a regex (or maybe not, I never used them), you still have to maintain it like any other code. When the time comes, it is far preferable to have a test script that will loop through all of your old test inputs (plus the new ones that caused the need to change) in a few seconds, instead of sitting on a website for tens of minutes, if not hours. trying to remember all of your test inputs and manually restart them to make sure you didn't break anything.

0


source







All Articles