Regex Tester
Test regular expression patterns on sample text, highlight matches, inspect capture groups and see replace results instantly.
All operations run in your browser. Your regex pattern and test text are not sent to a server.
Test your regular expression
Enter the pattern, the flag options and the test text using JavaScript RegExp syntax.
Test text
0 charactersMatch preview
0 matchesYou can use $& for the whole match, $1, $2 for numbered groups, and $<groupName> for named groups.
Match details
0 resultsReplace result
Regex Tester features
The core features you need to build, test and debug regular expressions and try out replace operations are offered on a single page.
Regex pattern testing
Tests regular expressions written in JavaScript RegExp syntax on sample text.
Flag support
Supports the global, case-insensitive, multiline, dot-all and Unicode flag options.
Match highlighting
Visually highlights the parts of the text that match the regex in the result area.
Capture groups
Shows the values of numbered and named capture groups separately.
Replace preview
Lets you preview regex replace expressions in the result area before changing the original text.
Secure processing in the browser
Your regex pattern and test text are processed on your device and are not sent to any server.
What is the Regex Tester?
The Regex Tester is a free online developer tool that runs regular expression patterns on sample text, highlights the matching parts and displays capture groups.
Regex, or regular expression, is a special pattern language used to search for, validate, extract or replace specific character structures in text. Data with a specific format, such as email addresses, phone numbers, URLs, dates, usernames and log lines, can be detected with regex patterns.
Although regular expressions are powerful, they can become complex because of special characters, groups, quantifiers and flag options. With the Regex Tester you can instantly see which texts a pattern matches, where each match starts and which values the groups capture.
This tool uses the JavaScript RegExp engine. As a result, there may be minor syntax and feature differences compared with regex engines in other programming languages.
How to use the Regex Tester?
Follow the steps below to test your regular expression.
Enter the regex pattern
Type the regular expression you want to test into the regex field without slashes at the start and end.
Select the flag options
Enable the global, case-insensitive, multiline, dot-all or Unicode options as needed.
Add the test text
Type or paste the text to check the regex pattern against into the test field.
Review the results
Check the matches, character positions, capture groups and the replace preview.
Regex test example
The following regex pattern can be used to find basic email address structures in text.
Regex pattern
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b
Test text
For project details, you can write to bilgi@teknodanisman.com or destek@teknodanisman.com.
Matches found
bilgi@teknodanisman.com
destek@teknodanisman.com
When the global g flag is enabled, all matches in the text are found. When the global flag is turned off, only the first match is reported.
What do the regex flag options do?
Flag options determine how the regular expression works on the text and how matches are evaluated.
| Flag | Name | Function | Example use |
|---|---|---|---|
g
|
Global | Finds all matches instead of stopping at the first one. | Finding all email addresses in a text |
i
|
Ignore case | Ignores the difference between uppercase and lowercase letters. |
Matching tekno with TEKNO |
m
|
Multiline |
Makes the ^ and $ anchors work on every line. |
Checking the start of each line |
s
|
Dot all | Lets the dot character also match line breaks. | Capturing multiline content blocks |
u
|
Unicode | Makes the regex engine process the pattern according to Unicode rules. | Matching emoji and Unicode code points |
Commonly used regex expressions
The following character classes, quantifiers and anchors are widely used in regular expressions.
Any character
By default, the dot matches any character except a line break.
Digit character
The \d expression matches digit characters from zero to nine.
Word character
\w matches letters, digits and the underscore character.
Whitespace character
\s matches whitespace characters such as spaces, tabs and line breaks.
Character class
Matches any one of the characters inside the square brackets.
Negated character class
Matches characters that are not listed inside the square brackets.
Zero or more
Allows the previous expression to repeat zero or more times.
One or more
Requires the previous expression to appear at least once.
Optional
Allows the previous expression to appear zero or one time.
Repetition range
Specifies that the previous expression repeats at least n and at most m times.
Start and end
^ denotes the start, and $ the end of the text or line.
Capture group
Groups multiple expressions and allows the matched value to be used later.
Common regex mistakes
1. Not escaping special characters
teknodanisman.com
In regex, the dot means any character. To match the literal dot in a domain name, use teknodanisman\.com.
2. Using an overly broad pattern
.*
This expression can match the widest possible content. To avoid unexpected results, character classes and boundaries should be defined more precisely.
3. Ignoring the behavior of the global flag
/\d+/
Without the global flag, only the first match is found. To find all number groups in the text, the g flag must be enabled.
4. Unclosed parenthesis or character class
(abc
[0-9
An unclosed parenthesis or square bracket causes a regex syntax error. The Regex Tester reports these errors during processing.
Where is regex used?
Regular expressions are used in many software development processes where specific character patterns need to be found, validated, extracted and replaced.
Form validation
Can be used to check the formats of email addresses, phone numbers, usernames, postal codes and passwords.
Log analysis
Used to extract IP addresses, error codes, timestamps and specific messages from log records.
Text search and replace
Enables bulk replacement of specific patterns in code editors or data files.
Data cleaning
Used to remove unnecessary whitespace, special characters or repeated text structures.
URL routing
Can be used on web servers to match URL patterns and create redirect rules.
Web scraping and data extraction
Can be used to extract specific values from structured text.
Frequently Asked Questions About the Regex Tester
Browse the answers to frequently asked questions about regular expressions, regex flag options, matches, capture groups and replace operations.
What is the Regex Tester used for?
What is regex?
Should I add slashes at the start and end of the regex pattern?
What does the regex global flag do?
g flag makes the regex engine find all matches in the text instead of stopping at the first one.How do I write a case-insensitive regex?
i flag. The Case-insensitive option in the Regex Tester enables this flag.What is a regex capture group?
How do I use a named capture group?
(?<groupName>...). In a replace operation, this group can be used with the $<groupName> expression.How do I perform a regex replace?
$& for the whole match and $1 and $2 for capture groups.Why does a regex produce an error?
Is JavaScript regex the same as regex in other languages?
Is my test text sent to a server?
Is the Regex Tester free?
Free Developer Tools
Free online tools you can use in software development, API integration, data conversion, testing and productivity workflows.