From baihaoquan at gmail.com Sun Jun 5 12:36:37 2011 From: baihaoquan at gmail.com (bai haoquan) Date: Sun, 5 Jun 2011 20:36:37 +0800 Subject: [regex-coach] Need a Regex to return multi result if matching more than one times Message-ID: Hi all, I want a regex used in Perl which is @ret = $query =~ /(googl.?)|(.?oogle)/; if the $query is "google", then will be matched, and the @ret = (google, undef), $1 = "google", $2 is undef but I want result like @ret = (google, google), because the pattern "(.?oogle)" is matched too, And my regex is very long (the regex above is just an example), maybe thouands of "|", so if separate the regex to /(googl.?)/ and /(.?oogle)/ will be inefficient. Does anybody can help me? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at illsoft.com Mon Jun 13 18:42:22 2011 From: mike at illsoft.com (mike) Date: Mon, 13 Jun 2011 14:42:22 -0400 Subject: [regex-coach] Regex Coach \K option fails? Message-ID: <4DF65A0E.7050009@illsoft.com> From the PCRE docs: The escape sequence \K causes any previously matched characters not to be included in the final matched sequence. For example, the pattern: foo\Kbar matches "foobar", but reports that it has matched "bar". http://www.pcre.org/pcre.txt This fails in The Regex Coach. Why? Thanks From edi at agharta.de Mon Jun 13 18:53:23 2011 From: edi at agharta.de (Edi Weitz) Date: Mon, 13 Jun 2011 20:53:23 +0200 Subject: [regex-coach] Regex Coach \K option fails? In-Reply-To: <4DF65A0E.7050009@illsoft.com> References: <4DF65A0E.7050009@illsoft.com> Message-ID: Hi, Regex Coach is not based on the C library PCRE. It's based on CL-PPCRE which is a Lisp library I wrote myself. You can find a link to it and its documentation on the website. Cheers, Edi. On Mon, Jun 13, 2011 at 8:42 PM, mike wrote: > From the PCRE docs: > > The escape sequence \K causes any previously matched characters not to be > included in the final matched sequence. For example, the pattern: > > ? ? ? ? foo\Kbar > > matches "foobar", but reports that it has matched "bar". > > http://www.pcre.org/pcre.txt > > > This fails in The Regex Coach. Why? > > Thanks > > _______________________________________________ > regex-coach site list > regex-coach at common-lisp.net > http://common-lisp.net/mailman/listinfo/regex-coach > From mike at illsoft.com Mon Jun 13 19:10:56 2011 From: mike at illsoft.com (mike) Date: Mon, 13 Jun 2011 15:10:56 -0400 Subject: [regex-coach] Regex Coach \K option fails? In-Reply-To: References: <4DF65A0E.7050009@illsoft.com> Message-ID: <4DF660C0.1070508@illsoft.com> I see, thanks. I checked that page but I don't see any mention of the \K option. Am I to assume that its not supported in your library? Is there a similar switch? Thanks, Mike On 6/13/2011 2:53 PM, Edi Weitz wrote: > Hi, > > Regex Coach is not based on the C library PCRE. It's based on > CL-PPCRE which is a Lisp library I wrote myself. You can find a link > to it and its documentation on the website. > > Cheers, > Edi. > > > > On Mon, Jun 13, 2011 at 8:42 PM, mike wrote: >> From the PCRE docs: >> >> The escape sequence \K causes any previously matched characters not to be >> included in the final matched sequence. For example, the pattern: >> >> foo\Kbar >> >> matches "foobar", but reports that it has matched "bar". >> >> http://www.pcre.org/pcre.txt >> >> >> This fails in The Regex Coach. Why? >> >> Thanks >> >> _______________________________________________ >> regex-coach site list >> regex-coach at common-lisp.net >> http://common-lisp.net/mailman/listinfo/regex-coach >> > > _______________________________________________ > regex-coach site list > regex-coach at common-lisp.net > http://common-lisp.net/mailman/listinfo/regex-coach > From edi at agharta.de Mon Jun 13 19:19:07 2011 From: edi at agharta.de (Edi Weitz) Date: Mon, 13 Jun 2011 21:19:07 +0200 Subject: [regex-coach] Regex Coach \K option fails? In-Reply-To: <4DF660C0.1070508@illsoft.com> References: <4DF65A0E.7050009@illsoft.com> <4DF660C0.1070508@illsoft.com> Message-ID: On Mon, Jun 13, 2011 at 9:10 PM, mike wrote: > I checked that page but I don't see any mention of > the \K option. Am I to assume that its not supported in your library? Right. Actually, until now I had never heard of the \K switch (or I forgot about it). CL-PPCRE is largely modeled on Perl (at a particular point in time) and when I wrote CL-PPCRE, Perl didn't have \K. > Is there a similar switch? >From a quick look at the PCRE docs I'd say that some of the \K behavior can probably be emulated using look-behind assertions. From mike at illsoft.com Mon Jun 13 19:34:47 2011 From: mike at illsoft.com (mike) Date: Mon, 13 Jun 2011 15:34:47 -0400 Subject: [regex-coach] Regex Coach \K option fails? In-Reply-To: References: <4DF65A0E.7050009@illsoft.com> <4DF660C0.1070508@illsoft.com> Message-ID: <4DF66657.8060101@illsoft.com> Ok, thanks for your help Mike On 6/13/2011 3:19 PM, Edi Weitz wrote: > On Mon, Jun 13, 2011 at 9:10 PM, mike wrote: >> I checked that page but I don't see any mention of >> the \K option. Am I to assume that its not supported in your library? > > Right. Actually, until now I had never heard of the \K switch (or I > forgot about it). CL-PPCRE is largely modeled on Perl (at a > particular point in time) and when I wrote CL-PPCRE, Perl didn't have > \K. > >> Is there a similar switch? > >> From a quick look at the PCRE docs I'd say that some of the \K > behavior can probably be emulated using look-behind assertions. > > _______________________________________________ > regex-coach site list > regex-coach at common-lisp.net > http://common-lisp.net/mailman/listinfo/regex-coach > From lists at frankmarion.com Tue Jun 14 02:34:02 2011 From: lists at frankmarion.com (Frank Marion) Date: Mon, 13 Jun 2011 22:34:02 -0400 Subject: [regex-coach] Regex Coach \K option fails? In-Reply-To: References: <4DF65A0E.7050009@illsoft.com> Message-ID: <9AFA6DC6-B88E-419C-A87B-3842B305942E@frankmarion.com> Ah-HA! Now it all falls into place. You were tired of Lisping when you typed, and so needed something to quickly find-and-replace those anomalous distortions. The universe is starting to make more and more sense. On 2011-06-13, at 2:53 PM, Edi Weitz wrote: > Regex Coach is not based on the C library PCRE. It's based on > CL-PPCRE which is a Lisp library I wrote myself. -- Frank Marion lists [_at_] frankmarion.com