freesabai

Developer tools

Regex tester

Type a regular expression and some test text and see where it matches. Matches are highlighted in the text and listed in a table with the groups they capture. Try a replacement with $1. If a regex runs so long that it would hang (ReDoS), the tool stops it within 1 second and the page never freezes. It runs in your browser.

This tool needs JavaScript. If you still see this after a few seconds, JavaScript is switched off in your browser or the page did not load completely: turn JavaScript on or reload the page.

How to use it

  1. Type the regex between the / / and choose the flags (g, to find every match, is on by default), or choose one from "Examples".
  2. Type or paste the test text. Matches are highlighted at once, and the table below gives the position and captured groups of each.
  3. Tick "Try a replacement" and give the replacement ($1 is group 1, $<name> a named group) to see the whole text after it.

Frequently asked questions

My regex makes the browser hang. Why?

Some regexes, such as (a+)+$, try every way of splitting the characters when the text does not match, and the time doubles with each extra character (called catastrophic backtracking, or ReDoS). In this tool the matching runs in a background worker, and if it takes more than 1 second it is stopped. Your page does not freeze, and you are told it is probably ReDoS.

Can I use regexes from other languages (Python, PHP, Java)?

This tool uses the browser's engine, so the syntax is JavaScript's. Much is the same, but some things differ: a named group is written (?<name>…) in JavaScript, not Python's (?P<name>…), and JavaScript has no inline flags such as (?i). The result is exactly right for JavaScript code; for other languages, check again.

How do I match Thai letters?

Use the range [\u0E00-\u0E7F]+, which covers Thai consonants, vowels and tone marks. Try the "Thai letters" example. Note that JavaScript's \w and \b do not know Thai letters (they count only a-z, 0-9 and _). To match letters of every language, use the u flag with \p{L} and \p{M}.

Good to know

Your data stays on your device

Everything runs in your browser. What you type, paste or open is not sent to freesabai's servers or anyone else's, and is not kept in the browser: close the page and it is gone. The site only counts how many times this page was opened and how many times someone copied or saved a result (never what was pasted or the result, and you can switch the counting off in the footer; see the privacy policy).

Report a problem or suggest an idea

Found a bug, or want this tool to do more? Tell us on the feedback page. No sign-up.

Other developer tools

JSON and data

Encoding, hashes and tokens

Generators

Time, numbers and colour

Text and code