python - Regex match if not before and after -
How can I 'suck' if not part of 'Honeyxi'?
Look-alings and see if I can match sucking if I do not 'Honey' or 'Suck', but it also fails to catch something like 'Honnisk'; Here the expression should , as it does not end in You're behind the nest Assertion of: An equivalent solution would be le :
re.search (r '(? & Lt;! Honey) ) Suck (?! Li) ',' Hoanseckar ')
& gt; & Gt; & Gt; Import re & gt; & Gt; & Gt; Regex = re.compile (r "(? & Lt;! Honey (? = Suck)) suck")> gt; & Gt; & Gt; Regex.search ("Honuscle") & gt; & Gt; & Gt; Regex.search ("honeysucker") & lt; _sre.SRE_Match object 0x00000000029B6370 & gt; & Gt; & Gt; & Gt; Regex.search ("suckle") & lt; _sre.SRE_Match object 0x00000000029B63D8 & gt; & Gt; & Gt; & Gt; Regex.search ("suck") & lt; _sre.SRE_Match object 0x00000000029B6370 & gt;
suck (?! (? & Lt; = honeysuck) le) .
Comments
Post a Comment