I know this question has been asked before but earlier today I found the following code in SO:
import re
def findIfWordMatch(w):
return re.compile(r'\b({0})\b'.format(w), flags=re.IGNORECASE).search
For example if I use the following strings the function return a match object if text1 is found in text2 (otherwise the function return None):
text1 = 'DIBUJO'
text2 = 'DIBUJO B308'
So to know if text1 is in text2 I do the following:
if(findIfWordMatch(text1)(text2) is not None):
#doSomething()
And it has been working well until I used these variables:
text1 = 'INT.EST.C.S.'
text2 = 'INT.EST.C.S. B308'
Im almost sure it has nothing to do with the dots because I have other variables with a similar structure and in works just fine so..
I would like to know why is this happening or another way to find if a string is inside another.
Thanks in advice