Thread View: news.software.readers
2 messages
2 total messages
Started by »Q«
Sat, 29 Jan 2005 00:38
[Xnews] PCRE question
Author: »Q«
Date: Sat, 29 Jan 2005 00:38
Date: Sat, 29 Jan 2005 00:38
29 lines
2205 bytes
2205 bytes
I'm seeing an unexpected result in Xnews' regex tester when a .*
follows a lookbehind assertion.
ISTM the regex (?<=foo).* should match the last three letters of the
string "foobar", but it doesn't. (?<=foo).+ does result in a match.
I've marked this [Xnews] only because I see the behavior there, but
it seems to happen with PCRE generally, and I can't explain it. I'm
hoping someone here can.
I actually ran across it using GNU grep (v 2.5.1) with the -P
switch, which makes grep use libpcre instead of POSIX regexes.
$ echo foobar | grep -P "(?<=foo).*"
results in no match. Both Xnews and grep are relying on Philip
Hazel's library.
OTOH, with The Regex Coach, which uses a different engine for
Perl-compatible regex, the regex (?<=foo).* does match the last
three letters of "foobar", as I expected.
Any thoughts/comments/explanations welcome. Especially
explanations.
--
»Q«
links to Xnews resources:
<http://www.cotse.net/users/putty/help.htm>
Re: [Xnews] PCRE question
Author: me
Date: Sat, 29 Jan 2005 01:27
Date: Sat, 29 Jan 2005 01:27
36 lines
2217 bytes
2217 bytes
»Q« <boxcars@gmx.net> wrote in »news:MrQ9602BD05FD0F0itsmeitsQ@QsFQDN.dyndns.org: > I'm seeing an unexpected result in Xnews' regex tester when > a .* follows a lookbehind assertion. > > ISTM the regex (?<=foo).* should match the last three > letters of the string "foobar", but it doesn't. (?<=foo).+ > does result in a match. > > I've marked this [Xnews] only because I see the behavior > there, but it seems to happen with PCRE generally, and I > can't explain it. I'm hoping someone here can. > > I actually ran across it using GNU grep (v 2.5.1) with the > -P switch, which makes grep use libpcre instead of POSIX > regexes. > > $ echo foobar | grep -P "(?<=foo).*" > > results in no match. Both Xnews and grep are relying on > Philip Hazel's library. > > OTOH, with The Regex Coach, which uses a different engine > for Perl-compatible regex, the regex (?<=foo).* does match > the last three letters of "foobar", as I expected. > > Any thoughts/comments/explanations welcome. Especially > explanations. > Interesting. The tester matches (?<=foo)(.)* Explanation: better not from me - I wouldn't dare. ;). J -- Replies to: Nherr1professor2doktor31109(at)Oyahoo(dot)Tcom
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads