When a regex looks right but doesn't match, the pattern is rarely wrong in an interesting way. It's usually one of a dozen ordinary causes: the input has a character you can't see, a backslash was lost in a string, a special character isn't escaped, an anchor or flag is missing, or the code runs the regex differently from your tester . Below is a checklist in the order worth checking, with examples.
The examples run JavaScript's engine; where Python or another language behaves differently, the item says so.
First, a 60-second method
Print the input exactly. In Python, print(repr(text)) shows hidden characters as escapes like \xa0 (a non-breaking space), \u200b (a zero-width space) or \r . In JavaScript, [...text].map(c => c.codePointAt(0).toString(16)) lists every character's code, so a0 or 200b stands out.
Shrink the pattern. Delete pieces from the end until it matches, then add them back one by one.…