Free Regex Tester Online – Test Regular Expressions Instantly
Test, debug, and perfect your regular expressions with our free online regex tester. Type a pattern and a test string, and see all matches highlighted in real time. Supports JavaScript regex syntax with global (g), case-insensitive (i), and multiline (m) flags. No account needed, fully browser-based.
WHAT IS REGEX
What is a Regular Expression?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. These patterns can be used to match, search, replace, or validate text in virtually any programming language. Regular expressions were first developed in the 1950s by mathematician Stephen Cole Kleene as part of formal language theory, and they have since become one of the most powerful and universally supported tools in programming.
At their core, regular expressions consist of literal characters and metacharacters. Literal characters match themselves (for example, the pattern “cat” matches the text “cat”), while metacharacters like ., *, +, ?, [], {}, ^, and $ have special meanings that enable complex pattern matching. A pattern like \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b can match any valid email address in a body of text.
Regular expressions are used in almost every area of software development: form validation in web apps, text search and replace in code editors, log parsing in server administration, data extraction in web scraping, and routing in web frameworks like Express.js and Django. Mastering regular expressions is one of the highest-leverage skills a developer can acquire.
How to Use the Regex Tester
- Step 1:Type your regular expression pattern in the input field between the two / slashes at the top.
- Step 2:Toggle the flags you want using the g, i, and m buttons on the right. “g” finds all matches (global), “i” ignores case, “m” makes ^ and $ match line boundaries.
- Step 3:Type or paste your test string into the “Test String” text area.
- Step 4:All matching parts of your test string will be highlighted in real time. The status bar shows the total number of matches found and the number of capture groups.
COMMON REGEX PATTERNS
Useful Regex Patterns to Get You Started
- Email address:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} - URL:
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b - Phone number (US):
(\+1)?[\s.-]?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4} - IP address:
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b - Date (YYYY-MM-DD):
\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]) - Hex color code:
#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}) - Strong password:
(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}
Frequently Asked Questions
What regex flavor does this tester use?
This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript standard. If you're writing regex for JavaScript, Node.js, or browser-based applications, the results will be accurate.
What does the "g" flag do?
The "g" (global) flag tells the regex engine to find all matches in the test string rather than stopping after the first match. Without "g", only the first match is returned.
What is a capture group in regex?
A capture group is a part of a regex pattern enclosed in parentheses, such as (\d+). It "captures" the matched text so you can reference it separately in replacements or code.
Why does my regex throw an error?
Errors usually come from unescaped special characters. For example, if you want to match a literal dot, you need to write \. instead of . (which matches any character). Also check for unbalanced parentheses or brackets.
