Online Regex Tester

Write and test regular expressions directly in your browser. Highlight matching text, inspect capture groups, check match positions and experiment with JavaScript regex flags.

1. Regular expression

Enter your regular expression and select the flags you want to use.

/ g
Enter the pattern without surrounding slash delimiters. Example: \d+ rather than /\d+/g.

2. Test text

Enter the text you want to search. Matching sections will be highlighted below.

0 characters

3. Match highlighting

Matched portions of your test text are highlighted.

No results yet
Run a regex test to see highlighted matches here.
0 Matches
0 Capture groups
0 Unique matches

4. Match details and capture groups

Inspect each match, its position in the text, and the values captured by your groups.

# Match Start End Capture groups
Run a test to display match details.

5. Test replacement

Test how your regex behaves when replacing matching text. JavaScript replacement syntax is supported.

Your replacement result will appear here.
Tip: $& inserts the entire match. $1 inserts the first capture group. $$ inserts a literal dollar sign.

Common regex examples

Select a pattern to load it into the tester.

Regular expression quick reference

Expression Meaning Example
. Any character except line terminators, unless using the s flag. a.c
\d A digit from 0 to 9. \d+
\w A word character: letters, digits and underscore. \w+
\s Whitespace characters. \s+
^ Beginning of input or line with m flag. ^Hello
$ End of input or line with m flag. end$
* Zero or more repetitions. ab*
+ One or more repetitions. \d+
? Zero or one repetition. colou?r
{n,m} Between n and m repetitions. \d{2,4}
[abc] Any one character from the set. [aeiou]
[^abc] Any character not in the set. [^0-9]
(abc) Capturing group. (\d{4})
(?:abc) Non-capturing group. (?:https?)
| Alternation (OR). cat|dog
\b Word boundary. \bcat\b
(?=...) Positive lookahead. \d(?=px)
(?!...) Negative lookahead. \d(?!px)

JavaScript regex flags explained

g - Global

Find all matches instead of stopping after the first match.

i - Ignore case

Match uppercase and lowercase letters without distinguishing between them.

m - Multiline

Make the beginning and end anchors work at individual line boundaries.

s - DotAll

Allow the dot character to match line terminators as well.

u - Unicode

Enable Unicode-aware regular expression processing.

y - Sticky

Require each match to start at the current regular expression position.

d - Match indices

Expose start and end indices for the complete match and its capture groups.

Frequently Asked Questions

What is a regular expression?

A regular expression, often called regex or regexp, is a pattern used to search, match, validate or manipulate text. It is commonly used in programming, data processing, form validation and text analysis.

How do I test a regular expression?

Enter a regex pattern, select the desired flags, and paste your test text into the text field. The tester highlights matches and displays their positions and capture groups.

What are capture groups?

Capture groups are sections of a regular expression enclosed in parentheses. They allow you to extract specific parts of a match. For example, (\d{4})-(\d{2})-(\d{2}) captures the year, month and day separately.

What is the difference between global and non-global matching?

A global expression using the g flag finds multiple matches. Without the global flag, the tester returns only the first match.

Does this tester use JavaScript regex syntax?

Yes. It uses the regular expression engine built into JavaScript. Some syntax supported by other regex engines, such as certain PCRE-specific features, may not work here.

Can I use this tool to validate email addresses?

You can test basic email-like patterns, but email validation is more complicated than a single regular expression. For important applications, combine reasonable client-side checks with server-side validation and email confirmation.

Is my test text uploaded?

No. This tool performs regex matching directly in your browser. The entered pattern and test text are not sent to the LifeAfterFlex server.

Explore more free tools

Discover other useful tools on LifeAfterFlex: