DEV Community

Discussion on: Why regular expression is a hot topic and why is it hard?

Collapse
 
xowap profile image
Rémy 🤖

It's like any tool, if you know it it helps you a lot but if you don't then you don't realize what you miss.

I remember my early coding days when all I know was antiquated languages like BASIC or PHP and I spent my time doing explode/strpos. Now I just fire regular expressions for any occasion and it feels really simple.

I believe it's hard for several reasons:

  1. It's totally unreadable
  2. It's very abstract. Specifically, you can consider it an abstraction on top of finite state machines but that is usually not a concept that beginners know, so they kind of have to understand it from cryptic gibberish and that is not nice

Related to usage, I'm currently developing a regular expression engine that handles other things than just strings. So I'd say that usage is anything that involves looking at patterns in a stream of data, be it validating an email address or putting together a sequence of UDP messages.