DEV Community

Discussion on: How do you regex?

Collapse
 
piyushkmr profile image
Piyush Kumar Baliyan

I use Regexr (regexr.com) to quickly test out my regexes. It supports JS style regex. and is very handy since it has features like live preview, and explanation of your regex.

For explaining regex, I mostly try to create simple and small regex, and assign it to some const (or function) to make it understandable.
e.g. I'll never do if (/regex/.test(str)), but always const EMAIL_REGEX = /regex/, and then my code.

For solving problems, I use it to sometimes modify data structures on the fly, and code refactor.
I also recently wrote a post about it: dev.to/admitkard/regexp-cheatsheet...