Python Regex Tester – re.findall, sub, split Online
NEWPython regex tester for the re module: (?P<name>) groups, re.I/M/S/X/A flags, and search, match, fullmatch, findall, split and sub shown as Python prints them.
Runs 100% in your browser — your input is never uploaded or stored on our servers.
Matches (3)
| search() | <re.Match object; span=(9, 19), match='2024-05-17'> |
|---|---|
| match() | None |
| fullmatch() | None |
| findall() | [('2024', '05', '17'), ('2024', '06', '02'), ('2025', '01', '15')] |
| finditer() | 3 matches |
| split() | ['Released ', '2024', '05', '17', ', patched ', '2024', '06', '02', '.\nNext review: ', '2025', '01', '15', ''] |
| sub() | 'Released 17/05/2024, patched 02/06/2024.\nNext review: 15/01/2025' # 3 replacements |
| # | Group | Value | Span |
|---|---|---|---|
| 1 | group(0) | '2024-05-17' | (9, 19) |
| 1 · year | '2024' | (9, 13) | |
| 2 · month | '05' | (14, 16) | |
| 3 · day | '17' | (17, 19) | |
| 2 | group(0) | '2024-06-02' | (29, 39) |
| 1 · year | '2024' | (29, 33) | |
| 2 · month | '06' | (34, 36) | |
| 3 · day | '02' | (37, 39) | |
| 3 | group(0) | '2025-01-15' | (54, 64) |
| 1 · year | '2025' | (54, 58) | |
| 2 · month | '01' | (59, 61) | |
| 3 · day | '15' | (62, 64) |
Translated JavaScript pattern
/(?<year>\p{Nd}{4})-(?<month>\p{Nd}{2})-(?<day>\p{Nd}{2})/uimport re
pattern = re.compile(r'(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2})')
text = 'Released 2024-05-17, patched 2024-06-02.\nNext review: 2025-01-15'
print(pattern.findall(text))Quick Examples
Typical inputs and the results this tool produces.
Overview
This Python regex tester checks patterns written for Python's re module, not JavaScript. Browsers only have a JavaScript regex engine, so the tool translates Python syntax first: (?P<name>…) becomes a named group, (?P=name) a backreference, \A and \Z become absolute anchors, $ also matches before a final newline, . stops only at \n, and \d, \w, \s and \b follow Python's Unicode rules unless re.ASCII is set. Verbose patterns lose their whitespace and # comments exactly as Python would.
Results are printed the way Python prints them: a <re.Match object; span=…> for search, match and fullmatch, lists and tuples for findall and split (None for groups that did not take part), and the sub() result using Python replacement syntax such as \1 and \g<name>. Spans count code points like Python, not UTF-16 units.
Constructs JavaScript cannot run — possessive quantifiers, atomic groups and conditionals — are reported clearly instead of being silently mis-handled. Everything runs in your browser.
Why use this tool?
- Test Python syntax without opening a Python shell
- Output looks exactly like Python repr()
- All seven re functions side by side
- Copy a ready-to-run Python snippet
- Clear errors with the position in the pattern
Features
Python flavour
(?P<name>), (?P=name), \A, \Z, inline (?imsx) flags and verbose mode are translated before matching.
Seven functions
search, match, fullmatch, findall, finditer, split and sub with count/maxsplit, evaluated together.
Match highlighting
Every match is highlighted in the test string, including empty matches.
Group table
Numbered and named groups with values and Python spans for each match.
Honest limits
Possessive quantifiers, atomic groups, conditionals and variable-width look-behind are flagged.
Python snippet
Generates re.compile code with the right raw string and flags for the function you pick.
How to Use
Enter the pattern
Type it as you would inside r'…' in Python and tick the flags you use.
Add a test string
Paste the text to search; matches are highlighted as you type.
Read the results
Compare search, findall, split and sub output in the Python results table.
Copy the code
Pick a function under Python code for and press Copy code.