DEV Community

Discussion on: How do you regex?

Collapse
 
sherrydays profile image
Sherry Day

I like this approach from the other thread

I love using regular expressions. And try to adopt the following pattern:

  1. Write a method for evaluating the regular expression.
  2. Bombard that method with tests, both matching and non-matching cases.
  3. Profit!

Regular expressions can be quite dense to read, so I want to use the tests to highlight my expectations around what I wrote.