From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 24 Oct 2008 13:27:20 +0200 From: Aharon Robbins To: 9fans@9fans.net, rudolf.sykora@gmail.com Message-id: <200810241127.m9OBRKGB004251@skeeve.com> Content-transfer-encoding: 7BIT Subject: Re: [9fans] non greedy regular expressions Topicbox-Message-UUID: 26177dd6-ead4-11e9-9d60-3106f5b1d025 You are not missing anything. Subexpression matching means when you have an expression like q(a+b)(c*d)z that you can get access to the exact text matched by the two parenthesized subexpressions. You asked about non-greedy regular expressions which were first popularized by perl. IIRC the Plan 9 regex library does not provide this at all; Bell Labs code never did non-greedy regexp matching. Rob and/or Russ can correct me if I'm wrong. FWIW, tools from the GNU world also do not support non-greedy matching, nor are such expressions part of POSIX. Hope this helps, Arnold > > russ has a great writeup on this. > > http://swtch.com/~rsc/regexp/ > > i think it covers all your questions. > > > > - erik > > I read trough some of that already yesterday. Anyway, am still > puzzled. In the text of > > Regular Expression Matching Can Be Simple And Fast > (but is slow in Java, Perl, PHP, Python, Ruby, ...) > > R. Cox writes: > --- > While writing the text editor sam [6] in the early 1980s, Rob Pike > wrote a new regular expression implementation, which Dave Presotto > extracted into a library that appeared in the Eighth Edition. Pike's > implementation incorporated submatch tracking into an efficient NFA > simulation but, like the rest of the Eighth Edition source, was not > widely distributed. > ... > Pike's regular expression implementation, extended to support Unicode, > was made freely available with sam in late 1992, but the particularly > efficient regular expression search algorithm went unnoticed. The code > is now available in many forms: as part of sam, as Plan 9's regular > expression library, or packaged separately for Unix. > --- > > But any manual page (regexp(6), that of sam) keeps completely silent > about eg. any submatch tracking. > So what's wrong? Can anybody clarify the situation for me or do I > really have to read the codes? > > Ruda >