Regular expressions are just like everything in programming. Used properly they are a huge boon. Used improperly, they're a disaster.
Here's a practical example. I spent half a day coding this algorithm (ASCII string in STEP format to an array of Unicode code points) in 70 lines of C++ without regular expression. It took me 15 minutes to recode it in Perl 6 using regular expressions:
while $step.chars > 0 {
given $step {
when /^ '\\S\\' (.)/ {
@unicode.push(ISO8859toUnicode($page, 128 | $0.ord ));
}
when /^ '\\P' (.) '\\'/ {
$page = $0.ord - 'A'.ord + 1;
}
when /^ '\\X' [ '2' | '4' ] '\\' (<hexdigits>+) '\\X0\\'/ {
@unicode.push(:16($0));
}
when /^ (.)/ {
@unicode.push($0.ord);
}
}
$step = $/.postmatch;
}
This (admittedly completely untested) version is drastically shorter and much less brittle.
I use them constantly but almost always BRE. And I'm still discovering new tricks using only BRE. I guess I'm too dumb to use anything more clever. I'll never be a Larry Wall. I still feel I have more to learn just on the level of BRE. I still think there are more hidden gems.
A lot of developers seem to have a serious disdain for anything that might be construed as the "lowest common denominator". I don't get it.
Somehow I find a tremendous versatility in the LCD. It works in so many environments. I can rely on it to work, no matter what the size of the input.
But then, if you go buy a book on RE, what do you get? An explanantion of the most ridiculously complex and difficult to maintain RE. As if the author is just showing off.
Mastery of the basics is too boring I guess. Too simple.
So what are they? Great?
Seriously, how do we describe developers who have a visceral perversion toward complexity?
There are a lot of developers who love complexity.