DEV Community

Discussion on: What are some Regular Expression concepts you find hard to grok?

Collapse
 
ajcwebdev profile image
ajcwebdev

I said this on Twitter but for me the thing that trips me up is constantly having to translate in my head between the thing I want to do in a regular expression and the specific regex syntax I need to accomplish it. The regex mental model is actually quite simple but the syntax is a nightmare.

Collapse
 
pinotattari profile image
Riccardo Bernardini

I agree. I actually like regular expressions, I find that they are a very powerful tool. However, the syntax leaves somehow to desire... It is not too bad for simple stuff (e.g., regexp for identifiers, especially with POSIX extension), but when the regexp gets complex (e.g., regexp for floating point numbers...) they look like a cat walking on the keyboard.

I tried to search for a different syntax, compact as the existing, but more readable but with no result. In the end I wrote myself a "regexp building" library that proves useful for the most complex cases.

Collapse
 
ajcwebdev profile image
ajcwebdev

This is awesome, thank you for sharing!