Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Monks, I came across this regex in my compilers course. It isn't particularly advanced, in terms of Perl's regex capabilities, but it's complex enough to give pause to most of the students in this (fourth-year undergraduate) course. Spend a few minutes figuring out, for instance, the ten shortest strings that it'll match:
Bonus points if you notice a pattern in the set of strings that it matches.... Update: Silly me. In the context of this course, regexes describe languages, they don't match strings. In that context, anchors aren't useful. (Finite Automata match strings, and you can build FAs from regexes automatically.) But I brought this example over to a Perl context, and played with the terminology just a bit to make it friendlier... and slipped up. Anchors added, thanks to all who pointed it out. -- In reply to Regex refresher by FoxtrotUniform
|
|