Free Regex Tester Online

Test, debug, and master regular expressions with real-time matching, pattern explanation, and multi-language support.

Real-time Multi-Language Cheat Sheet Explanation Free Forever
/ /
Cheat Sheet
. Any char \d Digit \w Word char \s Whitespace ^ Start $ End * 0+ + 1+ ? 0 or 1 [abc] Set
Enter a pattern and test string to see matches
No match information available.
Capture Groups
No groups captured.
Enter a valid regex to see explanation.

How to Use the Regex Tester

Testing regular expressions is quick and easy with our free online regex tool. Follow these simple steps:

  1. Enter your regex pattern - Type your regular expression between the slashes. Add flags like g (global), i (case-insensitive), m (multiline), or s (dotall).
  2. Provide a test string - Enter or paste the text you want to match against your pattern in the test area.
  3. See real-time matches - Matching text is highlighted instantly as you type. Green highlights show successful matches.
  4. View match details - Check the Match Info tab for match count and capture groups, or the Explanation tab to understand your pattern.
  5. Try common patterns - Click examples like Email, URL, or Date in the Reference tab to load pre-built patterns.
100% Private: All regex testing happens in your browser using JavaScript. Your patterns and test strings are never sent to any server.

What is a Regular Expression (Regex)?

Regular expressions (regex or regexp) are sequences of characters that define a search pattern. They are incredibly powerful tools for text processing, used for string matching, validation, search-and-replace, and data extraction. Regex is supported in nearly every programming language including JavaScript, Python, PHP, Java, Ruby, and more.

Character Classes
.Any character (except newline)
\dDigit [0-9]
\wWord character [a-zA-Z0-9_]
\sWhitespace (space, tab, newline)
[abc]Character set (a, b, or c)
[^abc]Negated set (not a, b, or c)
Quantifiers
*0 or more (greedy)
+1 or more (greedy)
?0 or 1 (optional)
{n}Exactly n times
{n,m}Between n and m times
*?0 or more (lazy/non-greedy)

Common Regex Patterns

Here are some frequently used regular expression patterns for validation and data extraction:

Email
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$

Validates email format like user@domain.com

Phone
^\+?[\d\s-]{10,14}$

Matches phone numbers with optional + prefix

URL
^https?:\/\/[\w\.-]+\/?.*$

Matches HTTP and HTTPS URLs

Frequently Asked Questions About Regex

This tester uses the JavaScript regex engine. While most syntax is universal, there are differences: Python uses re module with different flag syntax, PHP uses PCRE with features like possessive quantifiers (++) and recursion ((?R)) not available in JavaScript. Always test in your target language.

  • g (global) - Find all matches, not just the first
  • i (case-insensitive) - Ignore uppercase/lowercase differences
  • m (multiline) - ^ and $ match start/end of each line
  • s (dotall) - . matches newlines too

Capture groups use parentheses () to extract specific parts of a match. For example, ^(\d{4})-(\d{2})-(\d{2})$ matching "2024-01-23" captures: Group 1 = "2024", Group 2 = "01", Group 3 = "23". Use (?:...) for non-capturing groups when you need grouping but don't need to extract.

Greedy quantifiers (*, +, {n,m}) match as much as possible. Lazy quantifiers (*?, +?, {n,m}?) match as little as possible. Example: for string <p>Hello</p><p>World</p>, pattern <p>.*</p> matches the entire string (greedy), while <p>.*?</p> matches only <p>Hello</p> (lazy).

Use a backslash \ to escape special regex characters: . * + ? ^ $ { } [ ] \ | ( ). For example, to match a literal period, use \. instead of .. To match a backslash, use \\.