Regex Tester Online

Run a JavaScript regular expression on text: all matches with positions, numbered and named groups, replace and split, with protection against runaway patterns.

Free tool: 20 requests per minute.

Result

Press “Run” to see the result.

The regex API runs a regular expression (JavaScript / ECMAScript syntax, as in browsers and Node.js) on a text of up to 100,000 characters. action=match (the default) returns every match with its start and end position and the value and position of each numbered and named group; test returns true / false, replace applies a replacement with $1, $<name> and $&, and split splits the text.

Flags are the usual g i m s u v y (and d, used internally for group positions). Without g, match returns the first match only. Invalid patterns return a 400 with the error of the engine, so the API also works as a validator for patterns typed by users.

Patterns with a nested quantifier such as (a+)+ or (\w*\s?)*, which can take exponential time on some inputs, are rejected with unsafe_pattern. Results are limited to 1,000 matches (limit, default 100); count still gives the total.

Use this in your code

curl -X POST "https://apibox.io.vn/v1/regex" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pattern":"(?<user>[\\w.]+)@([\\w.]+)","flags":"g","text":"a@x.com, b.c@y.vn"}'

API documentation → Get a free API key

FAQ

Which regex flavour is used?

ECMAScript (V8), like JavaScript in browsers and Node.js. Lookbehind, named groups, Unicode property escapes (\p{L} with the u flag) and the v flag are supported.

Why was my pattern rejected as unsafe?

It has a quantified group containing another quantifier, the classic cause of catastrophic backtracking. Rewrite it (for example (a+)+ → a+) or use atomic alternatives.

How do I reference groups in a replacement?

$1, $2… for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal $.