[0-9] is not always equivalent to \d. In python3, [0-9] matches only 0123456789 characters, while \d matches [0-9] and other digit characters, for example Eastern Arabic numerals ٠١٢٣٤٥٦٧٨٩.

Answer from Kirill Polishchuk on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › what-does-d-mean-in-regex
Regular Expression Metacharacters - What Does \d Mean in RegEx?
March 2, 2023 - In this article, we’ll look at the RegEx character \d, which you can use to match a digit.
Discussions

regex - Python Regular Expression [\d+] - Stack Overflow
I am working on regular expression python, I came across this problem. A valid mobile number is a ten digit number starting with a 7,8 or 9. my solution to this was : if len(x)==10 and re.search(... More on stackoverflow.com
🌐 stackoverflow.com
In regular expressions what is the difference between r'[\d+] and r'[\d]+?
[ ] is a character set; it matches all the characters inside. [abc] would match any character out of 'a', 'b', and 'c'. \d is a character class for digits. \d and [\d] is the same thing: it matches any digit. + is one or more match, so \d+ matches one or more \d, and [\d]+ matches one or more [\d], which is the same thing. [\d+] matches a digit or a plus sign. More on reddit.com
🌐 r/learnprogramming
7
0
June 24, 2022
Str.extract(r'(\d+)')--- what does' \d+' mean?
Hi all! dont understand the pattern (r'(\d+)'), what we want to do here? My Code: combined_updated['institute_service_updated']=combined_updated['institute_service'].astype(str).str.extract(r'(\d+)') What I expected to happen: What actually happened: Replace this line with the output/error More on community.dataquest.io
🌐 community.dataquest.io
7
1
August 7, 2020
Understanding the (\D\d)+ Regex pattern in Python - Stack Overflow
I'm spending some time trying to understand the Regex terminology in Python 3 and I can't figure out how (\D\d)+ works here. I know that \D represents a nondigit character and that \d represents a... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Google
developers.google.com › google for education › python › python regular expressions
Python Regular Expressions | Python Education | Google for Developers
\d -- decimal digit [0-9] (some older regex utilities do not support \d, but they all support \w and \s) ^ = start, $ = end -- match the start or end of the string · \ -- inhibit the "specialness" of a character.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations — Python 3.14.7 ...
An enum.IntFlag class containing the regex options listed below. ... Make \w, \W, \b, \B, \d, \D, \s and \S perform ASCII-only matching instead of full Unicode matching.
🌐
NTU Singapore
www3.ntu.edu.sg › home › ehchua › programming › howto › Regexe.html
Regular Expression (Regex) Tutorial
Python supports Regex via module re. Python also uses backslash (\) for escape sequences (i.e., you need to write \\ for \, \\d for \d), but it supports raw string in the form of r'...', which ignore the interpretation of escape sequences - great for writing regex.
🌐
ThePythonGuru
thepythonguru.com › python-regular-expression
Python Regular Expression - ThePythonGuru.com
January 7, 2020 - All the special character and escape sequences loose their special meanings in raw string so \n is not a newline character, it's just a backslash \ followed by a n. Above we have used \d\d\d as pattern.
Find elsewhere
🌐
Bogotobogo
bogotobogo.com › python › python_regularExpressions.php
Python Tutorial: Regular Expressions with Python - 2021
The letter r tells Python that nothing in this string should be escaped; '\t' is a tab character, but r'\t' is really the backslash character \ followed by the letter t. We are better off to use raw strings when dealing with regular expressions; otherwise, things get too confusing too quickly.
🌐
Alexwlchan
alexwlchan.net › 2020 › what-does-d-match-in-a-regex
What does \d match in a regex? – alexwlchan
July 13, 2020 - Different languages handle this differently – for example, using \d in Python 3 will match all these numeric characters that aren’t Arabic numerals, but in Python 2 it won’t. No doubt it varies among other programming languages as well. How much this distinction matters depends on your use case, and in most cases I imagine the answer is “very little”. I present it more as an intellectual curiosity than something which needs serious consideration when writing regexes.
🌐
Dataquest Community
community.dataquest.io › q&a
Str.extract(r'(\d+)')--- what does' \d+' mean? - Q&A - Dataquest Community
August 7, 2020 - Hi all! dont understand the pattern (r'(\d+)'), what we want to do here? My Code: combined_updated['institute_service_updated']=combined_updated['institute_service'].astype(str).str.extract(r'(\d+)') What I expected to happen: What actually happened: Replace this line with the output/error
🌐
W3Schools
w3schools.com › python › python_regex.asp
Python RegEx
RegEx can be used to check if a string contains the specified search pattern. Python has a built-in package called re, which can be used to work with Regular Expressions.
🌐
TutorialsPoint
tutorialspoint.com › How-does-regular-expression-work-in-Python
How does [d+] regular expression work in Python?
April 23, 2025 - Here's how to use \d+ to find digits in a phone number ? import re phone_number = '234567890' pattern = r'\d+' result = re.search(pattern, phone_number) if result: print('Match found:', result.group()) print('True') else: print('False') ... ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-regex
Python RegEx - GeeksforGeeks
July 10, 2025 - In Python, the built-in re module provides support for using RegEx. It allows you to define patterns using special characters like \d for digits, ^ for the beginning of a string and many more.
🌐
Python documentation
docs.python.org › 3 › howto › regex.html
Regular expression HOWTO — Python 3.14.7 documentation
It’s also used to escape all the metacharacters so you can still match them in patterns; for example, if you need to match a [ or \, you can precede them with a backslash to remove their special meaning: \[ or \\. Some of the special sequences beginning with '\' represent predefined sets of characters that are often useful, such as the set of digits, the set of letters, or the set of anything that isn’t whitespace. Let’s take an example: \w matches any alphanumeric character. If the regex pattern is expressed in bytes, this is equivalent to the class [a-zA-Z0-9_]. If the regex pattern is a string, \w will match all the characters marked as letters in the Unicode database provided by the unicodedata module.
🌐
Regular-Expressions.info
regular-expressions.info › python.html
Python re Module - Use Regular Expressions with Python - Regex Support
The backslash is a metacharacter in regular expressions. It is used to escape other metacharacters. The regex \\ matches a single backslash. \d is a single token matching a digit. Python strings also use the backslash to escape characters. The above regexes are written as Python strings as ...
🌐
Mimo
mimo.org › glossary › python › regex-regular-expressions
Python Regex: Master Regular Expressions in Python
Master Python from basics to advanced topics, including data structures, functions, classes, and error handling ... Start your coding journey with Python. Learn basics, data types, control flow, and more ... It's best practice to define regex patterns using raw strings by prefixing the string with an r (e.g., r"\d+") to prevent backslashes from being misinterpreted.
🌐
Quora
quora.com › Is-there-any-difference-between-the-regular-expressions-0-9-and-d
Is there any difference between the regular expressions [0-9] and \d? - Quora
Answer (1 of 3): Yes, there are differences around the edges. Depending on your flavor of regex, \d may not be supported. (In my experience, that’s the biggest difference.) But depending on your implementation, \d might mean [0–9] or it might mean any Unicode character that’s a digit ...
🌐
Medium
gaurav-patil21.medium.com › tutorial-2-regular-expressions-in-python-using-regex-characters-w-s-d-99db4a9eb47
Tutorial 2: Regular Expressions in Python —Using regex metacharacters \w, \s, \d | by Gaurav Patil | Medium
August 28, 2022 - Tutorial 2: Regular Expressions in Python —Using regex metacharacters \w, \s, \d Missed previous tutorial ? — Click here When I started learning coding , I found that concepts are better …