r/programming
•
u/Dear-Economics-315
•
Aug 03 '26
•
1
The true power of regular expressions
https://www.npopov.com/2012/06/15/The-true-power-of-regular-expressions.html
117
Upvotes
109
u/Weird-Bluebird-132 Aug 03 '26
Article from 2012. Oh, that's not a criticism by the way. These days, it would be a Youtube video with popup heads in the corner and a horrible soundtrack.
32
u/w1n5t0nM1k3y Aug 03 '26
I found them a lot easier once I read a book explaining all the different features and terminology. Makes it a lot easier to find solutions when you know which keywords to use and what functionality is available.
The O'Reilly book on CSS was a great read. Really quick too because Regex is pretty simple. Half the book is just a language reference so you really only need to read the first half.
16
u/schadwick Aug 03 '26
The true power of regular expressions is demonstrated by this site.
21
u/Tringi Aug 03 '26
Nice article, but I ultimately disagree. The true power of regular expressions is in the UI. That a program offers them for the user to use for searching, filtering, etc.
4
u/mikeblas Aug 04 '26
The main problem is that regular expressions don't have a consistent implementation.
4
u/chucker23n Aug 05 '26
Just as a general comment on the various comments here saying regexes are difficult to comprehend: modern .NET offers
GeneratedRegex, which code-gens a "parser" behind the scenes thatAs an example of that latter point:
…is explained as:
Even the generated code is heavily commented. For example, "match a digit" becomes:
(Yes, there's everyone's favorite
gotoin there.)5
u/bigmell Aug 03 '26
With regular expressions you can match any text that has a predictable pattern and perform minute operations on the text matched, the text NOT matched, or the document itself. If you were matching text and you werent using regular expressions, basically what you were doing was re-writing the regular expression engine badly.
0
u/[deleted] Aug 03 '26
[deleted] — view deleted comment