⚡
usefultools.dev
re

Python Regex Tester – re.findall, sub, split Online

NOUVEAU

Python 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.

Fonctionne à 100 % dans votre navigateur — vos données ne sont jamais envoyées ni stockées sur nos serveurs.

Cet outil n'est pas encore entièrement traduit : une partie du texte est encore en anglais. L'outil lui-même fonctionne de la même façon dans toutes les langues.

Flags

Matches (3)

Released 2024-05-17, patched 2024-06-02. Next review: 2025-01-15
Python results
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
Groups (first 3 matches)
#GroupValueSpan
1group(0)'2024-05-17'(9, 19)
1 · year'2024'(9, 13)
2 · month'05'(14, 16)
3 · day'17'(17, 19)
2group(0)'2024-06-02'(29, 39)
1 · year'2024'(29, 33)
2 · month'06'(34, 36)
3 · day'02'(37, 39)
3group(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})/u
import 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))
⚡

Exemples rapides

Des entrées typiques et les résultats produits par cet outil.

Translate
(?P<y>\d{4})
(?<y>\p{Nd}{4})
findall
findall (\w)(\d)? on 'a1b'
[('a', '1'), ('b', '')]
split
split x* on 'abxd'
['', 'a', 'b', '', 'd', '']
fullmatch
fullmatch a|ab on 'ab'
span=(0, 2), match='ab'
Limit
a++
Possessive: not runnable in JS
📖

Présentation

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.

Pourquoi utiliser cet outil ?

  • 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
⭐

Fonctionnalités

🐍

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.

🛠️

Mode d'emploi

1

Enter the pattern

Type it as you would inside r'…' in Python and tick the flags you use.

2

Add a test string

Paste the text to search; matches are highlighted as you type.

3

Read the results

Compare search, findall, split and sub output in the Python results table.

4

Copy the code

Pick a function under Python code for and press Copy code.

🤔

Questions fréquentes