Developer Tools

Regex Tester

Test regular-expression matches against sample text locally.

Browser workspace
LOCAL PROCESSING

Input stays in this browser while you use the tool.

About this tool

The Regex Tester lets you try a regular expression against sample text and see which parts of the text it matches. A regular expression, or regex, is a compact pattern that describes a set of strings, for example "one or more digits" or "a word followed by an at sign". Developers use regular expressions to search text, check that input has the right format, extract values from logs and files, and find and replace patterns in code editors.

Writing a regex without testing it is risky. One missing backslash, one greedy quantifier or one forgotten flag can change the result completely, and the mistake often shows up only after the pattern is already in your code. A tester gives you instant feedback: you change the pattern, run it again and see at once which parts of the text match, before the pattern goes anywhere important.

A regular expression is built from a few kinds of parts. Literal characters match themselves. Character classes such as \d (a digit), \w (a letter, digit or underscore) and \s (a space) match groups of characters. Quantifiers such as *, +, ? and {2,4} say how many times something may repeat. Anchors such as ^ and $ mark the start and end, parentheses create groups, and the | sign means "or". Flags such as g and i change how the whole pattern behaves.

The tool runs in your browser, so it uses the JavaScript regular expression engine and the results match what you would get in JavaScript. Other languages such as Python, PHP and Java share most of the basic syntax, but some advanced features differ. Your text is processed on your own device and is not sent to the BitToolsKit server.

Use cases

  • Check an input format before you code it. Test a pattern for dates, postcodes, order numbers or usernames against both valid and invalid examples.
  • Extract values from logs and exports. Try a pattern that picks out IP addresses, error codes, ids or timestamps from a block of text.
  • Prepare a search or find-and-replace in your editor. Code editors and many other programs accept regular expressions, and a tester shows what a pattern would match before you change a whole project.
  • Clean up messy data. Find repeated spaces, stray symbols, inconsistent separators or unwanted prefixes in a list.
  • Debug a pattern that does not behave. Paste the same pattern and text that fail in your application and see whether the problem is the pattern, a flag or the way the pattern was copied into code.
  • Check rules for forms and routes. Test the patterns used in form validation, URL routing and configuration rules.
  • Learn how regex works. Start with small patterns and add one feature at a time, such as a quantifier, a group or a flag, to see its effect on the matches.

How to use

  1. Enter the regular expression you want to test. If you copied it from code written as /\d+/g, the slashes and the letters after the last slash are the delimiters and flags, not part of the pattern itself.
  2. Set any flags the tool offers. For example, g finds every match in the text and i ignores capital letters.
  3. Enter the text you want to test the pattern against.
  4. Click Run tool.
  5. Read the result in the Output box. It shows the matches that were found in your text. If nothing is found, the pattern does not match this text. If a message appears about an invalid pattern, correct the syntax and run the tool again.
  6. Change the pattern a little at a time and run it again until the matches are what you expect.
  7. Click Copy output to copy the result, Download to save it, or Clear to start again.

Test with text that should match and with text that should not match. A pattern that finds the right text can still be wrong if it also matches things you did not mean to include.

Examples

Example 1: Find all numbers

Pattern:
\d+
Flags: g

Test text:
Order 66 shipped 3 items on day 12.
What a regex tester reports:
3 matches: 66, 3, 12

Example 2: Find email-like text

Pattern:
[\w.+-]+@[\w-]+\.[\w.]+
Flags: g

Test text:
Contact ada@example.com or bob@test.org today.
What a regex tester reports:
2 matches: ada@example.com, bob@test.org
This simplified pattern finds text that looks like an email address. It is not a complete email validator.

Example 3: Capture groups in a date

Pattern:
(\d{4})-(\d{2})-(\d{2})
Flags: g

Test text:
Released on 2026-10-11.
What a regex tester reports:
1 match: 2026-10-11
The three pairs of parentheses create capture groups: 2026, 10 and 11. A tester that lists groups shows them as groups 1 to 3.

Example 4: Ignore case with the i flag

Pattern:
colou?r
Flags: gi

Test text:
Color, colour and COLOUR
What a regex tester reports:
3 matches: Color, colour, COLOUR

Example 5: Greedy and lazy matching (two separate runs)

Pattern A: <.+>
Pattern B: <.+?>
Flags: g

Test text:
<b>bold</b>
What a regex tester reports:
Pattern A (greedy): 1 match: <b>bold</b>
Pattern B (lazy): 2 matches: <b> and </b>

Example 6: An invalid pattern

Pattern:
(abc

Test text:
abc
What a regex tester reports:
No matches. An error message appears because the opening parenthesis is never closed. Add the missing ) and run the tool again.

Common errors

Only the first match is found

Without the g (global) flag a regex stops after the first match. Turn on the g flag if you want every match in the text.

A special character is not escaped, for example 3.14 also matching 3x14

In a regex a dot means any character. To match a literal dot write \. and do the same for other special characters such as ( ) [ ] { } * + ? ^ $ | and \ itself.

A message says the pattern is invalid

The pattern has a syntax error, most often a missing closing ) or ], a quantifier with nothing before it such as *abc, or a backslash at the very end. Count your brackets and parentheses and check each quantifier.

The match is far longer than expected

Quantifiers such as * and + are greedy by default and match as much as they can. Add a ? after the quantifier (.+? or .*?) to make it lazy, or use a narrower class such as [^>]+ instead of the dot.

^ and $ only match at the very start and end of the whole text

Without the m (multiline) flag, ^ matches only at the start of the text and $ only at the end. Turn on the m flag to match at the start and end of every line.

The dot does not match line breaks

By default the dot matches any character except a line break. Use the s (dotAll) flag, or write [\s\S] instead of the dot, to match across lines.

Capital letters are not matched

A regex is case-sensitive by default, so cat does not match Cat. Turn on the i flag to ignore case.

The pattern works here but fails in your code

A backslash inside a normal string needs doubling, so \d must be written as "\\d" in a JavaScript or Java string. In a JavaScript regex literal written as /\d/ you do not double it. Also check that your language uses the same regex syntax.

The page freezes on a pattern such as (a+)+b

Nested quantifiers can cause catastrophic backtracking, where the engine tries an enormous number of ways to match. Simplify the pattern, avoid repeating a group that can already match the same text, and test with short input first.

A feature from another language is not accepted, such as (?i) at the start, atomic groups or possessive quantifiers

The tool runs in your browser, which uses JavaScript's regex rules. Python, PHP, Java and .NET support some syntax that JavaScript does not. Use flags instead of inline flags such as (?i), and rewrite the pattern for JavaScript.

Frequently asked questions

What is a regular expression?

A regular expression, or regex, is a pattern made of ordinary characters and special symbols that describes a set of strings. It is used to search for text, check its format and extract parts of it.

What do the flags g, i, m, s, u and y do?

The g flag finds all matches instead of only the first, i ignores capital letters, m makes ^ and $ work on every line, s lets the dot match line breaks, u turns on full Unicode support and y matches only at the exact position where the search starts.

Which regex flavor does the tool use?

It runs in your browser, so it uses the JavaScript regex engine. The basic syntax is shared with Python, PHP, Java and other languages, but advanced features differ, so test a pattern in the language where you will use it as well.

What is the difference between greedy and lazy matching?

A greedy quantifier such as .+ matches as much text as possible, while a lazy quantifier such as .+? matches as little as possible. On <b>bold</b>, the pattern <.+> matches the whole string, and <.+?> matches <b> and </b> separately.

What are capture groups?

Parentheses around part of a pattern create a group that remembers the text it matched, so you can extract that part or reuse it in a replacement. A group written as (?:...) groups without capturing, and (?<name>...) gives a group a name.

How do I match a special character literally?

Put a backslash in front of it. To match a literal dot write \. , for a literal parenthesis write \( , and for a backslash write \\ .

Can I use a regex to validate email addresses?

A simple pattern can check that text looks like an email address, but checking every rule of the official format is very complicated. For real sign-ups, check the format loosely and confirm the address by sending a message to it.

Why does my regex freeze the page?

Some patterns, especially ones with nested quantifiers such as (a+)+, can take an extremely long time on certain text because the engine tries too many combinations. Simplify the pattern and test with short input first.

Does it support Unicode and emoji?

Use the u flag for full Unicode support. Without it, characters outside the basic range, such as many emoji, are treated as two separate characters, and Unicode property escapes such as \p{L} do not work.

Is my text uploaded to a server?

No. The tool runs in your browser and works on your device. As a general habit, avoid pasting passwords, API keys or private tokens into any online tool.

Related tools

Share this page