Python 3 interprets string literals as Unicode strings, and therefore \d is treated as an escaped Unicode character. Declare RegEx pattern as a raw string instead by prepending r or double escape \d