DEV Community

Discussion on: How do you regex?

Collapse
thumbone profile image
Bernd Wechner

My contexts for RE us in order of frequency of late:

  • Python
  • Bash
  • .NET (C#)

What tools do I use? In order again:

  • My IDE (as in I just write the thing, been writing Res since the '80s so pretty familiar with them)
  • The documentation for the tool (because different flavours trip me up from time tot time of course)
  • General on-line search (which generally takes me to the first)
  • On-line testing and diagnostic tools if I can't work out why my RE isn't matching when I think it should, including:

What types of problems?

  • RE problems, doh! ;-).
  • More seriously, the class of problem REs are idea for, which includes primarily:
    • Any spot need in Python or C# that I have to detect or extract specific patterns in a string
    • Using CLI tools in bash or writing shell scripts, it's not long before and RE in a grep or sed or such is called for.

Yeah, could be an age or generation thing but I call them REs not regexes so much.

Essentially REs fill the gap between:

  • The very basic string find, extract and split tools that many languages provide like like Excel does for example and basic string types in many modern languages provide
  • Full on grammar parsing.

In between these two extremes is a rich territory of spot pattern testing and string manipulation that a terse pattern definition language provides and the one that essentially came to dominate is called "regular" ;-), probably mainly because in its earliest inceptions it was designed and intended to be, supported by diverse tools in the *nix landscape of the day.