Advertisement

Search results

Searching...
Regular Expression
/ /
Test String
Highlighted Matches
Matches will be highlighted here...
Match Results 0

No matches yet. Enter a pattern and test string.

Quick Reference
.Any character except newline
\dDigit (0-9)
\DNon-digit
\wWord character (a-z, A-Z, 0-9, _)
\WNon-word character
\sWhitespace
\SNon-whitespace
^Start of string/line
$End of string/line
\bWord boundary
*0 or more
+1 or more
?0 or 1 (optional)
{n}Exactly n times
{n,m}Between n and m times
[abc]Any of a, b, or c
[^abc]Not a, b, or c
(abc)Capture group
(?:abc)Non-capturing group
a|ba or b

Regex Tester

Test and debug regular expressions with real-time matching

Advertisement

What is Regex Tester?

Regex Tester is a free online tool that lets you test regular expressions in real-time. Type your pattern, paste your test text, and instantly see all matches highlighted. No more guessing if your regex works - see the results as you type.

Why Would You Need to Test Regex?

Regular expressions can be tricky to get right. Here are common situations where this tool helps:

  • Validating user input: Test email, phone, or password patterns before adding them to your code
  • Data extraction: Check if your pattern correctly captures dates, URLs, or IDs from messy text
  • Find and replace: Test search patterns before running them on important files
  • Learning regex: Experiment with patterns and see exactly what matches without writing code
  • Debugging: Figure out why your regex is not matching what you expect

How to Test Regular Expressions - Step by Step

  1. Enter your pattern: Type your regex pattern in the input field at the top. The pattern goes between the forward slashes.
  2. Set your flags: Check the boxes for flags you need - "g" for global (find all matches), "i" for case-insensitive, and others.
  3. Paste your test text: Add the text you want to search through in the test string area.
  4. See results instantly: Matches are highlighted in the text, and detailed results appear on the right with position info and capture groups.

Key Features

  • Real-time testing: Results update as you type - no submit button needed
  • Match highlighting: See exactly where matches occur in your text with color coding
  • Capture groups: View all captured groups for each match, numbered automatically
  • All JavaScript flags: Support for g, i, m, s, and u flags with easy checkboxes
  • Common patterns library: One-click access to patterns for email, URL, phone, IP, and more
  • Quick reference: Built-in cheat sheet so you do not need to look up syntax
  • Error messages: Clear feedback when your pattern has syntax errors

Tips for Best Results

  • Start simple and add complexity gradually - test each part of your pattern
  • Use the "g" flag to find all matches, not just the first one
  • Remember to escape special characters like dots (.) and brackets when matching them literally
  • Click on common patterns to see real-world examples and learn from them

Frequently Asked Questions

Which regex flavor does this use?

This tool uses JavaScript regular expressions, which work in all modern browsers. Most patterns will also work in PHP, Python, and other languages with minor adjustments.

Why is my pattern not matching anything?

Check if your pattern has syntax errors (shown in red). Also make sure you are using the right flags - without "g", only the first match is found. Without "i", matching is case-sensitive.

What do the colors mean in highlighted results?

Yellow highlights show odd matches, and blue highlights show even matches. This alternating pattern helps you see where one match ends and another begins.

Can I test patterns for other programming languages?

JavaScript regex is compatible with most languages. However, some advanced features like lookbehinds may work differently. For language-specific testing, check the documentation for that language.

Is my data saved anywhere?

No. All processing happens in your browser. Your patterns and test text never leave your computer.

Advertisement