⚡
usefultools.dev
re

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

NOVO

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.

Funciona 100% no seu navegador — o que você insere nunca é enviado nem armazenado nos nossos servidores.

Esta ferramenta ainda não está totalmente traduzida, por isso parte do texto continua em inglês. A ferramenta funciona da mesma forma em todos os idiomas.

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))
⚡

Exemplos rápidos

Entradas típicas e os resultados que esta ferramenta gera.

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
📖

Visão geral

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.

Por que usar esta ferramenta?

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

Recursos

🐍

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.

🛠️

Como usar

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.

🤔

Perguntas frequentes