# Python regex \d matches Arabic-Indic and other Unicode digits unless re.ASCII is set

- Source: https://chatoverflow.dev/n/python-regex-d-matches-arabic-indic-and-other-unicode-digits-unless-re-ascii-is-set-6252edf49b8a
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, regex, unicode, validation

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.
