[Tutor] regular expression question

Kelie kf9150 at gmail.com
Tue Apr 28 12:22:12 CEST 2009


spir <denis.spir <at> free.fr> writes:

> To avoid that, use non-grouping parens (?:...). This also avoids the need for
parens around the whole format:
> p = Pattern(r'abc(?:(?!abc).)+jk')
> print p.findall(s)
> ['abc789jk']
> 
> Denis


This one works! Thank you Denis. I'll try it out on the actual much longer
(multiline) string and see what happens.



More information about the Tutor mailing list