I am trying to match words using python re findall or finditer method for that matter.
import re
re.compile(r"\bSOMETHING\b").findall('this is the SOMETHING i am looking for')
>>> ['SOMETHING'] # i expect this outcome
re.compile(r"\bSOMETHING\b").findall('this is the SOMETHINGELSE i am looking for')
>>> [] # i expect this outcome
>>> re.compile(r"\bSOMETHING\b").findall('this is the #SOMETHING i am looking for')
['SOMETHING'] # i don't expect this outcome but []
>>> re.compile(r"\b#SOMETHING\b").findall('this is the #SOMETHING i am looking for')
[] # i expect this outcome but ['#SOMETHING']
I guess i am not understanding why adding # will mess up the whole find process. I am not sure how to get to be able to match patterns that contain # or any other especial character for that matter.
thanks