What you are looking for is called fuzzy matching but unfortunately the re module doesn't provide this feature.

However the pypi/regex module has it and is easy to use (you can set the number of character insertion, deletion, substitution and errors allowed for a group in the pattern). Example:

>>> import regex
>>> regex.match(r'(?:anoother){d}', 'another')
<regex.Match object; span=(0, 7), match='another', fuzzy_counts=(0, 0, 1)>

The {d} allows deletions for the non-capturing group, but you can set the maximum allowed writing something like {d<3}.

Answer from Casimir et Hippolyte on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › re-match-in-python
re.match() in Python - GeeksforGeeks
July 23, 2025 - string: This is the string you want to check for the pattern. re.match will try to match the pattern only at the beginning of the string. flags (optional): This is an optional parameter that allows you to modify how the matching should behave. For example, you can use re.IGNORECASE to make the matching case-insensitive.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations
4 days ago - For example, a*a will match 'aaaa' because the a* will match all 4 'a's, but, when the final 'a' is encountered, the expression is backtracked so that in the end the a* ends up matching 3 'a's total, and the fourth 'a' is matched by the final ...
Discussions

regex - Regular expression matching in Python - Stack Overflow
I want to find two similar strings with at least one error. I want to use pythons built in re library. example import re re.match(r"anoother","another") #this is None indeed it should return Tr... More on stackoverflow.com
🌐 stackoverflow.com
How do you use re.match() ? Python
Can you give an example of a string you're trying to match? More on reddit.com
🌐 r/learnprogramming
8
1
August 16, 2022
Trouble capturing multiple string matches with re.findall() (Python)
The problem here is that you are overwriting your capture group because of the plus quantifier. And Python will only return result if the capture group if there is only one. See the doc you linked ( )+ Whatever gets saved here get overwritten every time the + matches another time. So only the last match gets saved in the group, and returned as a result. You have two options to fix it. Change the capture group to a non capture group: (?:\s*\w+\s*)+ This way Python will return the whole match. Because no capture group is present. Or make a capture group that saves all the characters between to brackets: ([^\]]+) Here all the matching is inside a single capture group so it does not get overwritten. I used a negative character set that will match anything that is not ]. More on reddit.com
🌐 r/regex
3
4
April 14, 2022
Regex-Like Pattern Matching on Arrays/Lists [Question]
Have a look at Egison . It should be a source of inspiration to anyone doing generalised pattern matching. [_,_/2] ~= [2,1]|[6,3] in particular is even clearer in Egison: $p :: #(p / 2). Rust and other languages allow to match sequences in lists, writing it [1, .., 2]. F#'s Active Patterns allow to parametrise branches, allowing us to do funky things like type MSpec<'a> = | Req of 'a | Opt of 'a let (|M|_|)<'a when 'a : equality> (xs: MSpec<'a> list) (ys: 'a list) = let rec f (xs': MSpec<'a> list) (ys': 'a list) = match xs' with | [] -> List.isEmpty ys' | (Opt xhd) :: xtl -> match ys' with | yhd :: ytl -> if xhd = yhd then f xtl ytl else f xtl ys' | _ -> f xtl ys' | (Req xhd) :: xtl -> match ys' with | yhd :: ytl -> if xhd = yhd then f xtl ytl else false | _ -> false in if f xs ys then Some () else None let g = function | M [Opt 1; Req 2; Req 3] -> printfn "matches\n" | _ -> printfn "nop\n" do g [1; 2; 3] //matches g [2; 3] //matches g [4; 2; 3] //nop Essentially, the discriminants accept parameters, which then let us manually implement custom matching mechanisms, including more general Turing-complete sublanguages if need be. Here I limited myself to optional elements like PCRE's and your x?. EDIT: I tried doing the same in Scala with an or function returning an anonymous object containing an unapply method, but the match expression doesn't like such parametric patterns. So I don't think Scala can do that. EDIT 2: Also, as you can see, if F# supported Egison's general value patterns (and not just compile-time constant value patterns), I could zip over xs' and ys' and simplify everything by doing | ((Opt xhd) :: xtl), (#xhd :: ytl) -> f xtl ytl, hence removing many LOCs. More on reddit.com
🌐 r/ProgrammingLanguages
17
20
February 1, 2023
🌐
W3Schools
w3schools.com › python › python_regex.asp
Python RegEx
Python has a built-in package called re, which can be used to work with Regular Expressions. ... You can add flags to the pattern when using regular expressions. A special sequence is a \ followed by one of the characters in the list below, and has a special meaning: A set is a set of characters inside a pair of square brackets [] with a special meaning: The findall() function returns a list containing all matches.
🌐
Python documentation
docs.python.org › 3 › howto › regex.html
Regular Expression HOWTO — Python 3.14.3 documentation
If you wanted to match only lowercase letters, your RE would be [a-z]. Metacharacters (except \) are not active inside classes. For example, [akm$] will match any of the characters 'a', 'k', 'm', or '$'; '$' is usually a metacharacter, but inside ...
🌐
Built In
builtin.com › articles › python-re-match
Python re.match() and re.sub() Explained | Built In
So, this example finds phone numbers in the 123-456-7890 format and converts them to (123) 456-7890. ... Contact me at (123) 456-7890 or (987) 654-3210. ... (): Used for capturing groups, allowing us to extract parts of the match and reference ...
🌐
Medium
medium.com › @niraj.e21 › python101-regular-expression-mastering-python-regex-in-simple-steps-afd22449eafe
Python101 Regular Expression: Mastering Python RegEx in Simple Steps | by Niraj Tiwari | Medium
March 26, 2024 - This object contains information about the match, including the start and end positions of the match in the string. — If the pattern is not found, `re.search()` returns `None`. In summary, this code is looking for the word “Python” in the string “Learning Python is fun”. Since “Python” is indeed present in the string, the output of this code will be `”Found: Python”`. For Example:How do we find all digits in the string “The cost of 2 apples is 3 dollars”?
Find elsewhere
🌐
Programiz
programiz.com › python-programming › regex
Python RegEx (With Examples)
The method returns a match object if the search is successful. If not, it returns None. There are other several functions defined in the re module to work with RegEx. Before we explore that, let's learn about regular expressions themselves. If you already know the basics of RegEx, jump to Python RegEx. To specify regular expressions, metacharacters are used. In the above example, ^ and $ are metacharacters.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Regular Expressions in Python: the re Module | note.nkmk.me
May 9, 2023 - re - Flags — Regular expression operations — Python 3.11.3 documentation · By default, unlike standard regular expressions, \w is not equivalent to [a-zA-Z0-9_]. For example, \w matches full-width alphanumeric characters, Japanese, etc.
🌐
Interactive Chaos
interactivechaos.com › en › python › function › rematch
re.match - Python
May 17, 2021 - The re.search function returns an object of type match or None if the match is not found at the beginning of the text string. ... We can check if the texts "my cat" or "my cats" are found at the beginning of several sentences with the following code: ... In this next example the regular expression is satisfied ("my cats"), but not at the beginning of the text, so the re.match function returns None (which is why nothing is displayed on the screen).
🌐
Mimo
mimo.org › glossary › python › regex-regular-expressions
Mimo: The coding platform you need to learn Web Development, Python, and more.
In this example, re.search() checks if the word "learn" exists in the text and returns the first match. Regex is commonly used in Python 3 for working with unicode strings.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-re-search-vs-re-match
re.search() vs re.match() - Python - GeeksforGeeks
July 12, 2025 - Explanation: re.match(r"^[A-Z]", "Hello world") checks if the string starts with an uppercase letter from A to Z and since "H" is uppercase at the beginning, it returns a match object.
🌐
Codecademy
codecademy.com › docs › python › regular expressions › re.match()
Python | Regular Expressions | re.match() | Codecademy
September 5, 2023 - The following example returns a match object (<re.Match object; span=(0, 12), match='123-456-7890'>) and not None since the phone number (123-456-7890) matches the test pattern: ... Learn the basics of regular expressions and how to pull and ...
🌐
Google
developers.google.com › google for education › python › python regular expressions
Python Regular Expressions | Python Education | Google for Developers
In Python a regular expression search is typically written as: ... The re.search() method takes a regular expression pattern and a string and searches for that pattern within the string. If the search is successful, search() returns a match object or None otherwise. Therefore, the search is usually immediately followed by an if-statement to test if the search succeeded, as shown in the following example which searches for the pattern 'word:' followed by a 3 letter word (details below):
🌐
PYnative
pynative.com › home › python › regex › python compile regex pattern using re.compile()
Python Compile Regex Pattern using re.compile()
April 2, 2021 - There are many flags values we can use. For example, the re.I is used for performing case-insensitive matching.
🌐
TestDriven.io
testdriven.io › tips › 421e050b-176b-4a72-a8b5-6ad5f185b86a
Tips and Tricks - Difference between re.search and re.match in Python? | TestDriven.io
Example: import re claim = 'People love Python.' print(re.search(r'Python', claim).group()) # => Python print(re.match(r'Python', claim)) # => None print(re.search(r'People', claim).group()) # => People print(re.match(r'People', claim).group()) ...
🌐
Educative
educative.io › answers › what-is-the-rematch-method-in-python
What is the re.match method in Python?
This means that re.match() will return the match found in the first line of the string, but not those found in any other line, in which case it will return null. ... re.U: Interprets letters according to the Unicode character set. How \w, \W, \b, and \B behave are usually affected. In the code example below, we use the re.match function to find a match in the pattern pattern from the list listString.
🌐
Python Tutorial
pythontutorial.net › home › python regex › python regex match()
Python Regex match
December 10, 2021 - In this tutorial, you'll learn how to use the Python regex match() function to find a match with a pattern at the beginning of a string.
🌐
Automate the Boring Stuff
automatetheboringstuff.com › 3e › chapter9.html
Chapter 9 - Text Pattern Matching with Regular Expressions, Automate the Boring Stuff with Python, 3rd Ed
For example, the characters \d in a regex stand for a decimal numeral between 0 and 9. Python uses the regex string r'\d\d\d-\d\d\d-\d\d\d\d' to match the same text pattern the previous is_phone_number() function did: a string of three numbers, a hyphen, three more numbers, another hyphen, ...
🌐
StrataScratch
stratascratch.com › blog › mastering-python-regex-a-deep-dive-into-pattern-matching
Mastering Python RegEx: A Deep Dive into Pattern Matching - StrataScratch
July 21, 2023 - Let’s start with a simple example. Let’s say you want to find all occurrences of the word “Python” in a string. We can use the findall() function from the re module. Here is the code. import re # Sample text text = "Python is an amazing programming language. Python is widely used in various fields." # Find all occurrences of 'Python' matches = re.findall("Python", text) # Output the matches print(matches)