This reg exp search correctly checks if the string contains harry text:
re.search(r'\bharry\b','[harry] blah',re.IGNORECASE)
However, I need to make sure the string contains [harry]. I tried to escape with various amounts of backslashes:
re.search(r'\b\[harry\]\b','[harry] blah',re.IGNORECASE)
re.search(r'\b\\[harry\\]\b','[harry] blah',re.IGNORECASE)
re.search(r'\b\\\[harry\\\]\b','[harry] blah',re.IGNORECASE)
None of these solutions find a match. What do I need to do?
Thank!
source
share