Jan-31-2020, 04:03 AM
Hi
I am trying to use lookbehind for a sample code as below
Can you please check if i am missing something.
I am trying to use lookbehind for a sample code as below
import re
txt = "love regex or hate regex, can't ignore regex"
pattern = re.compile("(?<=(love|hate)\s)regex")
pattern.findall(txt)The output of last line is ['love', 'hate']. But i am expecting the output to be['regex', 'regex'] at locations after love and hate.Can you please check if i am missing something.
