simple (?) re question

Darrell Gallion darrell at dorb.com
Tue Jul 11 16:36:47 EDT 2000


>>> re.match(("(?!.*SCCS).*java$"),"/foo/bar/SCCS/s.file.java")
>>> re.match(("(?!.*SCCS).*java$"),"/foo/bar/CCS/s.file.java")
<re.MatchObject instance at 8deaa8>
>>> re.findall(("(?!.*SCCS).*java$"),"/foo/bar/CCS/s.file.java")
['/foo/bar/CCS/s.file.java']

Maybe I can explain this.
The first ".*" eat up the "SCCS" before the negative assertion was
evaluated.
Moving ".*" into the negative assertion now says:
No where on this line can there be "SCCS"

--Darrell Gallion

----- Original Message -----
From: "Frederic Laurent" <laurent8 at sxb.bsf.alcatel.fr>
>
> >>> r=re.compile(".*(?!SCCS.*$).*[.]java$")
>
> and then
>
> >>> r.match("/foo/bar/SCCS/s.file.java")
> <re.MatchObject instance at 1f9898>
>
> But it's wrong for me ! I was expected this file will not match.
>






More information about the Python-list mailing list