9fans archive / 2008 / 10 / 345 / prev next From: Uriel <uriel99@gma...> Subject: Re: [9fans] non greedy regular expressions Date: Fri, 24 Oct 2008 19:10:02 +0200 On Fri, Oct 24, 2008 at 6:11 PM, Rudolf Sykora <rudolf.sykora@gma...> wrote: > Further, in R. Cox's text (http://swtch.com/~rsc/regexp/regexp1.html) > he claims that all nice features except for backreferences can be > implemented with Thomson's NFA algorithm. And even the backreferences > can be handled gracefully somehow. That is: ALL: non-greedy operators, > generalized assertions, counted repetitions, character classes CAN be > processed using the fast algorithm. Why then we don't have it? Just because something is possible doesn't mean that it is a good idea. Implementing every possible feature is the GNU/way, if you want to go down that path, you know where to find it. > I once > wrote a program in python and was pretty happy to have non-greedy > operators and lookahead assertions on hand. Should I hadn't had those, > I probably wouldn't have been able to write it (nicely). Python uses the absolutely dreadful and unintelligible PCRE, which not only have unpredictable performance as Russ points out, but are a total mess so complex that I doubt anybody fully understands them, they are to Plan 9 regexps what C++ is to C. Maybe Plan 9 regexps are not as 'powerful', but at least I can understand them. uriel