I know 'in' can find substring in another string just like this. [How to determine whether a substring is in a different string
But I could not how to find exactly substring in the below example:
text = '"Peter,just say hello world." Mary said "En..."'
I want to judge whether 'Peter' is in text but not in "XXXX" content. If I use
if 'Peter' in text:
print 'yes'
else:
print 'no'
But the result returns 'yes', which is wrong because 'Peter' is in "XXXXX".
Besides solving this problem, I want to get the left "XXXX" content. For example, 'Mary' is in text and not in "XXXX" content. I also want to get "Peter,just say hello world.".