🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations — Python 3.14.3 documentation
4 days ago - Source code: Lib/re/ This module provides regular expression matching operations similar to those found in Perl. Both patterns and strings to be searched can be Unicode strings ( str) as well as 8-...
🌐
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.
🌐
Python documentation
docs.python.org › 3 › howto › regex.html
Regular Expression HOWTO — Python 3.14.3 documentation
This document is an introductory tutorial to using regular expressions in Python with the re module. It provides a gentler introduction than the corresponding section in the Library Reference.
🌐
Medium
medium.com › @ebojacky › the-very-bare-minimum-essentials-for-regular-expressions-in-python-54e78c10b649
The Very Bare Minimum Essentials for Regular Expressions in Python | by Ebo Jackson | Medium
June 2, 2025 - Regex101: An interactive online tool for testing and debugging regex patterns with real-time feedback. Python’s re Documentation: The official documentation (docs.python.org/3/library/re.html) provides detailed explanations and examples.
🌐
Google
developers.google.com › google for education › python › python regular expressions
Python Regular Expressions | Python Education | Google for Developers
Regular expressions are a powerful language for matching text patterns. This page gives a basic introduction to regular expressions themselves sufficient for our Python exercises and shows how regular expressions work in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › python › regular-expression-python-examples
Python RegEx - GeeksforGeeks
August 14, 2025 - A Regular Expression or RegEx is a special sequence of characters that uses a search pattern to find a string or set of strings. It can detect the presence or absence of a text by matching it with a particular pattern and also can split a pattern ...
🌐
MicroPython
docs.micropython.org › en › latest › library › re.html
re – simple regular expressions — MicroPython latest documentation
Due to this, it’s not recommended to use raw Python strings (r"") for regular expressions. For example, r"\r\n" when used as the regular expression is equivalent to "rn". To match CR character followed by LF, use "\r\n". ... import re # As re doesn't support escapes itself, use of r"" strings is not # recommended. regex = re.compile("[\r\n]") regex.split("line1\rline2\nline3\r\n") # Result: # ['line1', 'line2', 'line3', '', '']
🌐
Rexegg
rexegg.com › regex-python.php
Python Regex Tutorial
Python Regex Tutorial. Discusses the Python re and regex classes, provides working code for matching, replacing and splitting.
Find elsewhere
🌐
PyPI
pypi.org › project › regex
regex · PyPI
In the regex (\s+)(?|(?P<foo>[A-Z]+)|(\w+) (?P<foo>[0-9]+) there are 2 groups: ... If you want to prevent (\w+) from being group 2, you need to name it (different name, different group number). The issue numbers relate to the Python bug tracker, except where listed otherwise.
      » pip install regex
    
Published   Feb 28, 2026
Version   2026.2.28
🌐
Real Python
realpython.com › ref › stdlib › re
re | Python Standard Library – Real Python
The Python re module provides support for working with regular expressions, allowing you to search, match, and manipulate strings using complex pattern descriptions.
🌐
Real Python
realpython.com › regex-python
Regular Expressions: Regexes in Python (Part 1) – Real Python
October 21, 2023 - In previous tutorials in this series, you've seen several different ways to compare string values with direct character-by-character comparison. In this tutorial, you'll learn how to perform more complex string pattern matching using regular expressions, or regexes, in Python.
🌐
Codecademy
codecademy.com › docs › python › regular expressions › re.search()
Python | Regular Expressions | re.search() | Codecademy
September 5, 2023 - Learn the basics of regular expressions and how to pull and clean data from the web with Python. ... Apply regular expressions (regex) and other natural language parsing tactics to find meaning and insights in the texts you read every day.
🌐
Python for Everybody
py4e.com › html3 › 11-regex
PY4E - Python for Everybody
It is possible to tell an asterisk ... your regex will match the very first instance rather than the last instance. In the example above, using .+?@ would instead match the first at-sign, the one in [email protected]. For more details, see the Python documentation on greedy ...
🌐
CircuitPython
docs.circuitpython.org › en › latest › docs › library › re.html
re – simple regular expressions — Adafruit CircuitPython 1 documentation
Due to this, it’s not recommended to use raw Python strings (r"") for regular expressions. For example, r"\r\n" when used as the regular expression is equivalent to "rn". To match CR character followed by LF, use "\r\n". ... import re # As re doesn't support escapes itself, use of r"" strings is not # recommended. regex = re.compile("[\r\n]") regex.split("line1\rline2\nline3\r\n") # Result: # ['line1', 'line2', 'line3', '', '']
🌐
Note.nkmk.me
note.nkmk.me › home › python
Regular Expressions in Python: the re Module | note.nkmk.me
May 9, 2023 - In Python, the re module allows you to work with regular expressions (regex) to extract, replace, and split strings based on specific patterns. re — Regular expression operations — Python 3.11.3 documentation
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions › Cheatsheet
Regular expression syntax cheat sheet - JavaScript | MDN
January 8, 2026 - This page provides an overall cheat sheet of all the capabilities of RegExp syntax by aggregating the content of the articles in the RegExp guide. If you need more information on a specific topic, please follow the link on the corresponding heading to access the full article or head to the guide.
🌐
Medium
medium.com › @AlexanderObregon › getting-started-with-regex-in-python-173972a40584
Getting Started with Regex in Python | Medium
November 14, 2024 - Learn how to use regex in Python with the re module. Validate input, search text, and perform replacements easily using practical examples.
🌐
Wikipedia
en.wikipedia.org › wiki › Regular_expression
Regular expression - Wikipedia
5 days ago - In Python and some other implementations (e.g. Java), the three common quantifiers (*, +, and ?) are greedy by default because they match as many characters as possible. The regex ".+" (including the double-quotes) applied to the string
Top answer
1 of 3
457

Since we're all guessing, I might as well give mine: I've always thought it stood for Python. That may sound pretty stupid -- what, P for Python?! -- but in my defense, I vaguely remembered this thread [emphasis mine]:

Subject: Claiming (?P...) regex syntax extensions

From: Guido van Rossum ([email protected])

Date: Dec 10, 1997 3:36:19 pm

I have an unusual request for the Perl developers (those that develop the Perl language). I hope this (perl5-porters) is the right list. I am cc'ing the Python string-sig because it is the origin of most of the work I'm discussing here.

You are probably aware of Python. I am Python's creator; I am planning to release a next "major" version, Python 1.5, by the end of this year. I hope that Python and Perl can co-exist in years to come; cross-pollination can be good for both languages. (I believe Larry had a good look at Python when he added objects to Perl 5; O'Reilly publishes books about both languages.)

As you may know, Python 1.5 adds a new regular expression module that more closely matches Perl's syntax. We've tried to be as close to the Perl syntax as possible within Python's syntax. However, the regex syntax has some Python-specific extensions, which all begin with (?P . Currently there are two of them:

(?P<foo>...) Similar to regular grouping parentheses, but the text
matched by the group is accessible after the match has been performed, via the symbolic group name "foo".

(?P=foo) Matches the same string as that matched by the group named "foo". Equivalent to \1, \2, etc. except that the group is referred
to by name, not number.

I hope that this Python-specific extension won't conflict with any future Perl extensions to the Perl regex syntax. If you have plans to use (?P, please let us know as soon as possible so we can resolve the conflict. Otherwise, it would be nice if the (?P syntax could be permanently reserved for Python-specific syntax extensions. (Is there some kind of registry of extensions?)

to which Larry Wall replied:

[...] There's no registry as of now--yours is the first request from outside perl5-porters, so it's a pretty low-bandwidth activity. (Sorry it was even lower last week--I was off in New York at Internet World.)

Anyway, as far as I'm concerned, you may certainly have 'P' with my blessing. (Obviously Perl doesn't need the 'P' at this point. :-) [...]

So I don't know what the original choice of P was motivated by -- pattern? placeholder? penguins? -- but you can understand why I've always associated it with Python. Which considering that (1) I don't like regular expressions and avoid them wherever possible, and (2) this thread happened fifteen years ago, is kind of odd.

2 of 3
50

Python Extension. From the Python Docs:

The solution chosen by the Perl developers was to use (?...) as the extension syntax. ? immediately after a parenthesis was a syntax error because the ? would have nothing to repeat, so this didn’t introduce any compatibility problems. The characters immediately after the ? indicate what extension is being used, so (?=foo) is one thing (a positive lookahead assertion) and (?:foo) is something else (a non-capturing group containing the subexpression foo).

Python supports several of Perl’s extensions and adds an extension syntax to Perl’s extension syntax.If the first character after the question mark is a P, you know that it’s an extension that’s specific to Python

https://docs.python.org/3/howto/regex.html

🌐
Dataquest
dataquest.io › cheat-sheet › regular-expressions-cheat-sheet
Python Regex Cheat Sheet – Dataquest
July 22, 2025 - This regular expressions cheat sheet provides a quick reference for essential RegEx constructs, helping you perform text pattern matching and manipulation with ease. It covers foundational syntax, such as character classes, anchors, and quantifiers, alongside advanced features like groups, ...