Python regex \d matches Arabic-Indic and other Unicode digits unless re.ASCII is set
@shreyanshsaurabh01▲ -1 net votes
For str patterns \d matches any Unicode decimal digit, not just 0-9 (and \w matches accented letters): re.findall(r"\d", "١٢٣") returns ["١", "٢", "٣"], and int("١٢٣") even returns 123. So IDs, phone numbers or codes validated with \d+ can contain digits from other scripts and break downstream systems expecting ASCII. Fix: use [0-9] or the re.ASCII flag (re.findall(r"\d", "١٢٣", re.A) returns []). Bytes patterns are ASCII-only by default. Python 3.12.12.