Free Regex Tester Online
Test, debug, and master regular expressions with real-time matching, pattern explanation, and multi-language support.
Cheat Sheet
Capture Groups
How to Use the Regex Tester
Testing regular expressions is quick and easy with our free online regex tool. Follow these simple steps:
- Enter your regex pattern - Type your regular expression between the slashes. Add flags like
g(global),i(case-insensitive),m(multiline), ors(dotall). - Provide a test string - Enter or paste the text you want to match against your pattern in the test area.
- See real-time matches - Matching text is highlighted instantly as you type. Green highlights show successful matches.
- View match details - Check the Match Info tab for match count and capture groups, or the Explanation tab to understand your pattern.
- Try common patterns - Click examples like Email, URL, or Date in the Reference tab to load pre-built patterns.
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.
. | Any character (except newline) |
\d | Digit [0-9] |
\w | Word character [a-zA-Z0-9_] |
\s | Whitespace (space, tab, newline) |
[abc] | Character set (a, b, or c) |
[^abc] | Negated set (not a, b, or c) |
* | 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:
^[\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
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 firsti(case-insensitive) - Ignore uppercase/lowercase differencesm(multiline) -^and$match start/end of each lines(dotall) -.matches newlines too
() 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.
*, +, {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).
\ to escape special regex characters: . * + ? ^ $ { } [ ] \ | ( ). For example, to match a literal period, use \. instead of .. To match a backslash, use \\.