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 le :

  re.search (r '(? & Lt;! Honey) ) Suck (?! Li) ',' Hoanseckar ')    

You're behind the nest Assertion of:

  & 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;   

An equivalent solution would be suck (?! (? & Lt; = honeysuck) le) .

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -