Blog

Free Online Regex Tester — Test Regular Expressions Instantly

Regular expressions are a pattern language for finding, extracting, and replacing text. A tester lets you see exactly what a pattern matches before you put it into code.

What regular expressions are

A regular expression (regex) is a sequence of characters that defines a search pattern. The pattern \d+ matches one or more digits. The pattern [a-zA-Z] matches any single letter. Combine them with quantifiers, anchors, and character classes to describe almost any text structure.

Regex is built into most programming languages. The syntax covered here follows JavaScript's regex engine, which is what browser-based testers use and is nearly identical to the regex in Python, PHP, Java, and most other languages for common patterns.

Common regex patterns

\d matches a digit (0–9). \w matches a word character (letters, digits, underscore). \s matches whitespace. Add + after any of them to match one or more, * for zero or more, or ? for zero or one.

Anchors pin the match to a position: ^ matches the start of the string (or line in multiline mode), $ matches the end. A simplified email pattern like [^@]+@[^@]+\.[^@]+ reads: one or more characters that are not @, then a literal @, then more non-@ characters, then a literal dot, then more non-@ characters.

Regex flags: g, i, m

Flags modify how the engine applies the pattern. The g (global) flag finds all matches in the input, not just the first one. Without g, the engine stops after the first match — a common source of confusion when you expect multiple results and only get one.

The i (case-insensitive) flag makes the match ignore case, so /hello/i matches Hello, HELLO, and hello. The m (multiline) flag changes the meaning of ^ and $ — instead of matching the start and end of the entire string, they match the start and end of each line. Use m when your input has multiple lines and you want to match patterns at the beginning or end of each one.

How to test a regular expression

Open the regex tester, type your pattern into the pattern field (without the surrounding slashes), set your flags using the checkboxes, and paste your test string into the input area. Matches highlight in real time as you type.

Check the match list below the input to see each match's position and value. If you expect three matches and only see one, the missing flag is usually g. For structured text processing where you also need to compare two versions of a file, the text diff tool shows line-by-line differences.

Common regex mistakes

Forgetting the g flag when you need all matches is the most frequent error — the pattern is correct but only returns one result. The fix is adding g to the flags.

The dot . matches any character except a newline. Writing 3.14 as a pattern matches 3X14, 3014, and 3.14. To match a literal dot, escape it: 3\.14. Similarly, greedy quantifiers like .* consume as much as possible, which can match more than you intended. Switching to the lazy variant .*? stops at the earliest possible match. For complex patterns that span multiple lines, use the JSON formatter to clean up structured data before writing a regex to parse it.

From pattern to working match

Write a minimal pattern first and expand it. Start with a literal string to confirm the tester is finding the right lines, then add character classes and quantifiers to generalize. Test against both positive examples (strings that should match) and negative examples (strings that should not).

The regex tester shows match positions and groups, which makes it straightforward to iterate until the pattern is exact. Once the pattern works in the tester, copy it directly into your code — no translation needed.

Test your regex — free, in your browser

Paste your pattern and test string. Matches highlighted instantly. No account, nothing stored.

Test regex →