Regex Tester

Test a regex on your own text with highlighting and capture groups, get the expression explained piece by piece in plain words, and catch patterns that hang the parser.

/ /

Good to know

Matches and groups

Pattern breakdown

Ready-made code

Matching runs on the JavaScript engine. Python, PHP and Go use almost the same syntax, with a few differences — for one, JavaScript has no x flag for comments inside the pattern.

A regular expression is hard to read even for its own author, and a month later it is harder still. Regex Tester breaks one into parts and labels each part in plain words: where the start of a line is, where a capturing group sits, and what the lookahead ahead of it checks.

Regular expressions have a trap that can take down production servers. A pattern like (a+)+b run against a string of thirty identical letters forces the engine to try an ever-growing number of ways to split the string: one second, then a minute, then an hour. This is called catastrophic backtracking, and one line typed into a search form has been known to lay a site down this way.

We look for such constructions in your expression beforehand and explain in words what exactly is dangerous about them. The expression itself runs in a separate thread with a time limit: if it hangs, we cut it off, and the page stays alive.

Cyrillic behaves differently than expected

The shorthand \w in JavaScript matches a Latin letter, a digit, or an underscore, so Cyrillic letters do not fall under it. Next to Cyrillic, the word boundary \b also acts strangely. We notice such combinations in your text and suggest what to replace them with: an explicit set [а-яёА-ЯЁ] or character properties in Unicode mode.

Groups, replacement, and ready-made code

Matches appear in a table with positions and capture groups, and named groups print by name. A replacement mode turns on separately, so you see what the text will become. The tested expression is assembled into ready-made code for JavaScript, Python, PHP, and Go: escaping differs between these languages, and moving a regex by hand is a common source of errors.

The result recalculates as you type

Every keystroke brings a fresh set of matches right away, so the table and the highlights track the text as you edit it, with nothing to run manually.

Rate this tool

Help us get better

Other tools