Regex Tester | Developer Tools

Regex Tester

Test and debug regular expressions with this free online tool. See matches in real-time and get detailed information about your regex pattern.

Regular Expression

/ /

Test String

What is Regular Expression (Regex)?

Regular expressions (regex or regexp) are powerful sequences of characters that define search patterns. They are used for string searching, matching, and text manipulation operations. Regular expressions provide a concise and flexible means for identifying strings of text, such as particular characters, words, or patterns of characters.

Regular expressions are widely used in programming languages, text editors, and command-line tools for tasks like:

  • Validating input (like email addresses, phone numbers, dates)
  • Finding and replacing text
  • Extracting information from strings
  • Parsing and transforming text
  • Data scraping and cleaning

Basic Regex Syntax

Pattern Description Example
. Matches any single character a.c matches “abc”, “adc”, “a1c”, etc.
^ Matches start of string ^hello matches “hello world” but not “say hello”
$ Matches end of string world$ matches “hello world” but not “world view”
* Matches 0 or more occurrences ab*c matches “ac”, “abc”, “abbc”, etc.
+ Matches 1 or more occurrences ab+c matches “abc”, “abbc” but not “ac”
? Matches 0 or 1 occurrence ab?c matches “ac” and “abc” but not “abbc”
[abc] Character class – matches any character in brackets [abc] matches “a”, “b”, or “c”
[^abc] Negated character class – matches any character not in brackets [^abc] matches any character except “a”, “b”, or “c”

Understanding Regex Flags

Regex flags modify how the pattern matching behaves. They are added after the closing slash in the regex pattern. Our tool supports the following flags:

Flag Name Description
g Global Find all matches rather than stopping after the first match
i Case-insensitive Makes the pattern case-insensitive (e.g., /a/i matches both “a” and “A”)
m Multiline Makes ^ and $ match the start/end of each line, not just the start/end of the entire string

Common Regex Patterns

Email Validation

/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/

Validates email addresses with standard format.

URL Validation

/^(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/

Validates URLs with or without http/https.

Phone Number

/^\+?(\d{1,3})?[-. ]?\(?\d{3}\)?[-. ]?\d{3}[-. ]?\d{4}$/

Matches phone numbers in various formats.

Date (YYYY-MM-DD)

/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/

Validates dates in YYYY-MM-DD format.

Frequently Asked Questions

What’s the difference between .* and .*?

Both match any sequence of characters, but they behave differently. .* is greedy and matches as much as possible, while .*? is lazy (non-greedy) and matches as little as possible. For example, in the string “abc123def”, the pattern a.*d would match “abc123d”, but a.*?d would match “abcd”.

How do I match a literal special character like . or *?

To match a special character literally, you need to escape it with a backslash (\). For example, to match a period, use \.\ instead of .. Other special characters that need escaping include: ^ $ . * + ? ( ) [ ] { } | \ /.

What’s the difference between \d and [0-9]?

In most regex implementations, \d and [0-9] are equivalent and both match any digit. However, in some implementations (like Unicode-aware ones), \d might match other digit characters from different scripts, while [0-9] strictly matches ASCII digits.

How do I create a regex that matches a word boundary?

Use \b to match a word boundary. For example, \bword\b matches the complete word “word” but not “sword” or “wordsmith”. Word boundaries are positions between a word character (\w) and a non-word character (\W) or the beginning/end of the string.

What are capturing groups and how do they work?

Capturing groups are portions of a regex pattern enclosed in parentheses () that “capture” the matched text for later use. They allow you to extract specific parts of a match. For example, in the pattern (\d{3})-(\d{4}) applied to “123-4567”, the first group captures “123” and the second captures “4567”.

How can I make my regex more efficient?

To make regex more efficient:

  • Be specific – use character classes instead of wildcards when possible
  • Avoid excessive backtracking with .*
  • Use non-capturing groups (?:pattern) when you don’t need to extract the matched text
  • Anchor your patterns with ^ and $ when appropriate
  • Use possessive quantifiers or atomic groups for complex patterns

Is my data secure when using this tool?

Yes, all processing happens directly in your browser. Your regex patterns and test strings are never sent to our servers, ensuring complete privacy for sensitive data.