Use this free online Regular Expression Tester to test, validate, and debug regular expressions against sample text instantly. Whether you are building search patterns, validating user input, extracting data, or performing text replacements, this tool helps you verify that your regular expressions work exactly as expected.
Simply enter your regular expression pattern, provide the text to test against, select any regex flags you need, and instantly see matching results. You can also test replacement operations and troubleshoot patterns before using them in your applications.
Key Features Of This Tool
- Test regular expressions against text and instantly see matching results.
- Perform text replacement using regular expression patterns with an optional replacement field.
- Enable or disable common regex flags, including case-insensitive (
i), multiline (m), global (g), and dot matches all (s). - Matched text is highlighted to make it easy to identify successful pattern matches.
- Copy your regular expression, test text, or results with a single click.
Regular Expression (Regex) Reference Guide
Regular expressions (Regex) are pattern-matching rules used to search, validate, extract, or replace text. Whether you’re checking email addresses, validating passwords, filtering data, or finding specific words, regular expressions provide a fast and flexible solution.
The table below explains the most commonly used regex symbols and what they represent.
| Regex Pattern | Description |
|---|---|
Escapes special characters so they are treated as ordinary text. It is also used to introduce special sequences such as d, w, and s. | |
^ | Matches the start of a string. Inside square brackets ([^...]), it means “exclude these characters.” |
$ | Matches the end of a string or line. |
* | Repeats the previous character or group zero or more times. |
+ | Requires the previous character or group to appear one or more times. |
? | Makes the previous item optional. When used after another quantifier, it performs the shortest possible match (lazy matching). |
. | Represents any single character except a newline in most regex engines. |
(pattern) | Groups expressions together and stores the matched value for later use (capturing group). |
(?:pattern) | Groups expressions without saving the matched value (non-capturing group). |
(?=pattern) | Positive lookahead. Ensures the following text matches without including it in the result. |
(?!pattern) | Negative lookahead. Ensures the following text does not match. |
x|y | Matches either the expression before or after the pipe symbol. |
{n} | Matches the preceding item exactly n times. |
{n,m} | Matches the preceding item between n and m times. |
{n,} | Matches the preceding item at least n times. |
{,m} | Matches the preceding item up to m times (supported in some regex flavors). |
[abc] | Matches any one character listed inside the brackets. |
[^abc] | Matches any character except those inside the brackets. |
[A-Z] | Matches any uppercase letter within the specified range. |
[0-9] | Matches any numeric digit from 0 through 9. |
b | Matches the boundary between a word character and a non-word character. |
B | Matches positions that are not word boundaries. |
[b] | Matches the backspace control character rather than a word boundary. |
d | Matches any decimal digit (0–9). |
D | Matches any character that is not a digit. |
w | Matches letters, digits, and the underscore character. |
W | Matches any character that is not a letter, digit, or underscore. |
s | Matches whitespace characters including spaces, tabs, and line breaks. |
S | Matches any character that is not whitespace. |
t | Matches a horizontal tab character. |
n | Matches a newline character. |
r | Matches a carriage return character. |
f | Matches a form feed character. |
v | Matches a vertical tab character. |
cX | Matches a control character, where X is a letter from A to Z. |
| Matches the null character. | |
xhh | Matches a character represented by a two-digit hexadecimal value. |
uhhhh | Matches a Unicode character represented by a four-digit hexadecimal value. |
1, 2, etc. | References text captured by an earlier capturing group. Useful for detecting repeated patterns. |
Regex Flags
Regex flags modify how a pattern behaves during matching.
| Flag | Purpose |
|---|---|
i | Ignores letter casing, allowing uppercase and lowercase matches. |
g | Finds every occurrence instead of stopping after the first match. |
m | Treats each line as a separate string for ^ and $ anchors. |
s | Allows the dot (.) character to match newline characters. |
Regular Expression Patterns
Below are some of the most frequently used regular expressions for validation, searching, and text processing.
Match an Email Address
Use this pattern to match the general format of an email address.
Pattern
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,}$
Example Matches
- user@example.com
- john.doe@mail.co.uk
This pattern is suitable for most applications but does not guarantee that an email address actually exists.
Match an IPv4 Address
Validates the format of a standard IPv4 address.
Pattern
^(25[0-5]|2[0-4]d|1?d?d)(.(25[0-5]|2[0-4]d|1?d?d)){3}$
Example Match
192.168.1.100
Validate a Date (YYYY-MM-DD)
Checks whether a date follows the ISO format.
Pattern
^d{4}-d{2}-d{2}$
Example Match
2026-06-27
This checks the format only. It does not verify whether the date is a real calendar date.
Match Integers
Positive integers only.
^d+$
Positive or negative integers.
^-?d+$
Match Decimal Numbers
Accepts whole numbers and decimals.
^-?d+(.d+)?$
Examples
- 15
- -25
- 99.95
Match Hexadecimal Color Codes
Matches both 3-digit and 6-digit hex colors.
^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
Examples
- #FF6600
- #FFF
- 00CC99
Match Letters and Numbers Only
Useful for usernames and identifiers.
^[A-Za-z0-9]+$
Match URLs
Matches URLs beginning with HTTP or HTTPS.
^https?://.+$
Examples
- http://example.com
- https://example.com
Remove HTML Tags
Use this expression with the Replace feature and leave the replacement field empty.
<[^>]+>
Remove Empty Lines
Enable the Global (g) and Multiline (m) options.
Pattern
^s*r?n
Replacement
Leave empty.
Match Duplicate Consecutive Words
Finds repeated words such as “the the”.
b(w+)s+1b
Match Passwords (Minimum 8 Characters)
Requires at least one uppercase letter, one lowercase letter, one digit, and one special character.
^(?=.*[a-z])(?=.*[A-Z])(?=.*d)(?=.*[@$!%*?&]).{8,}$
Match Phone Numbers
Simple international phone number format.
^+?[1-9]d{7,14}$
Examples
- +14155552671
- 2348031234567
Helpful Tips
- Start with simple patterns before creating complex expressions.
- Use the g flag to find every occurrence in the text.
- Use the i flag when letter case should be ignored.
- Escape special characters such as
.,(,),[, and?when matching them literally. - Test your regular expressions with several input examples to ensure they work as expected.