Reading this and some of the comments (that are incorrect!) -- combined with the fact that recent projects have provided me with a little more regex-fu, I've come to the conclusion that the non-greedy operator (ie, /[0-9]*?00/) is entirely too useful and is not given as much billing as it should -- people learn * really quickly, but right along with * should follow ? and an explanation of why it's cool. I guess mostly people just don't know of it?
|
|
Discussion (2)
it's mostly that people are not taught regexes. usually at best they are taught one or two regexes, or how to fake it, or how to read them (vaguely).
and when they are taught, it's often by people that weren't taught -- and tehrefore often by people who don't know.
The sad thing is that regular expressions are a required part of understanding automata, which is required for most compilers classes and theory of computation classes and most BS/BA CS degrees.
The problems are (1) they are usually taught theory rather than practice and (2) they aren't taught how to take that theory from the limited scope of automata and theory of computation and move it to a different problem set.