Skip to content
brainai.store

RegexLab

Type a pattern and some text to see matches and groups highlighted live, the pattern drawn as a diagram, patterns that could hang flagged, and a preview of any replacement. Copy it as code for five languages.

Runs in this tab. Nothing is uploaded. Keeps working if your connection drops.

Watch it work, on the app’s own sample
  • g on: every match is found, not just the first
  • i off: A and a are different
  • m off: ^ and $ match only at the start and end of the whole text
  • s off: . matches anything except a line break
  • u off: an emoji counts as two characters
  • v off: no set operations in [ ]
  • y off: a match can start anywhere

Start with a sample

  • See the pattern as a mapA railroad diagram drawn from the pattern: every route text can take, with groups boxed in their own colour.
  • Every match, part by partGroups coloured inside each match, a table of what each captured, and a step-through with [ and ].
  • Safe to try anythingPatterns run in a background worker that is stopped after 2 seconds, and a safety check spots patterns that could hang.
  • Take it with youReplace with a before-and-after preview, test cases that pass or fail, and code for JavaScript, Python, Go, PHP and Java.

JavaScript regex flavour. Text files up to 1 MB. Matches are found in the first 50,000 characters, up to 5,000 of them. A pattern that runs longer than 2 seconds is stopped. Nothing you type or open is saved or sent anywhere.

Pattern library

Load one to see how it works. Your text is kept if you have some.

Cheat sheet

Click a token to type it into the pattern.

Characters

Repeats

Groups and positions

What RegexLab can do

RegexLab’s railroad diagram of a date pattern: three coloured branches for ISO, day/month/year and “Mar 7, 2025” dates, with digit boxes, month and day choices and repeat loops