Skip to content
UtilHQ

Regex Tester

Regular expressions (regex) are powerful patterns used for finding, validating, and manipulating text across nearly every programming language.

100% Free No Data Stored Instant
Try:
//gi
2 matches
Contact: john@example.com or support@company.org

Quick Reference

\d digit
\w word
\s space
. any
+ 1+
* 0+
Ad Space
Ad Space

Share this tool

About This Tool

Regular expressions (regex) are powerful patterns used for finding, validating, and manipulating text across nearly every programming language. This free regex tester lets you write patterns and instantly see matches highlighted in your test string. Click any example above to see common patterns in action, or type your own pattern to test it against custom text. Validating emails, extracting phone numbers, parsing log files, and cleaning data all require regex as an essential developer skill. Writing and debugging patterns can be frustrating without visual feedback, which is why this tool highlights every match in real-time as you type. Our tool uses JavaScript's native RegExp engine, so patterns you build here work directly in your browser-based projects, Node.js applications, and any JavaScript runtime. Toggle flags to control matching behavior, and use the built-in quick reference to look up common syntax without leaving the page. All processing happens locally in your browser for complete privacy.

How to Use This Tool

Type your regex pattern in the input field (without the surrounding slashes). Paste or type your test text below. Matches are instantly highlighted in green as you type, with no need to click a button. Toggle flags to change matching behavior: Global finds all matches, Case Insensitive ignores capitalization, and Multiline makes ^ and $ match line boundaries. The match counter at the top right shows how many matches were found. Click any example button to load a pre-built pattern and sample text for common use cases like emails, phone numbers, URLs, dates, and hex colors.

Common Regex Patterns

  • Email: [\w.-]+@[\w.-]+\.[a-z]{2,} - Matches standard email addresses with domain extensions of two or more characters.
  • Phone: \(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4} - Matches US phone numbers in various formats including (555) 123-4567 and 555.123.4567.
  • URL: https?://[\w.-]+(?:/[\w./-]*)? - Matches HTTP and HTTPS URLs with optional paths.
  • Date (YYYY-MM-DD): \d{4}-\d{2}-\d{2} - Matches ISO 8601 date format strings.
  • IP Address: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} - Matches IPv4 addresses (basic pattern).

Understanding Flags

The Global (g) flag finds all matches instead of stopping at the first. Without it, only the first occurrence is highlighted. Case Insensitive (i) treats uppercase and lowercase letters as equivalent, so "abc" matches "ABC" and "Abc". Multiline (m) changes the behavior of ^ and $ anchors so they match the start and end of each line rather than the entire string. This is critical when testing patterns against multi-line text like log files or CSV data where each line should be matched independently.

Regex Syntax Quick Reference

The basic building blocks of regex include character classes like \d (any digit), \w (any word character: letters, digits, underscore), and \s (any whitespace). Quantifiers control repetition: + means one or more, * means zero or more, ? means zero or one, and {n,m} means between n and m occurrences. Anchors like ^ (start of string) and $ (end of string) constrain where matches can occur. Grouping with parentheses () captures sub-matches, while | acts as alternation (logical OR). Square brackets [] define custom character classes, and a caret inside brackets [^...] negates the class.

Performance Considerations

Regex engines can become slow with certain patterns, especially those involving nested quantifiers or excessive backtracking. A pattern like (a+)+b on a string of many "a" characters without a "b" can cause exponential backtracking, sometimes called "catastrophic backtracking." To avoid this, use atomic groups or possessive quantifiers where available, keep patterns as specific as possible, and avoid unnecessary capturing groups (use (?:...) for non-capturing groups). For very large text inputs, consider processing the data in chunks rather than applying a single regex to megabytes of text at once.

Frequently Asked Questions

Which regex flavor does this use?
This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript standard. Patterns you test here will work in all modern browsers (Chrome, Firefox, Safari, Edge) and in Node.js. Note that some features from other regex flavors like lookbehind assertions or atomic groups may have limited browser support.
How do I match a literal dot or special character?
Escape special characters with a backslash. For example, use \. to match a literal period, \$ for a dollar sign, \( for an opening parenthesis, and \\ for a literal backslash. Characters that need escaping include: . * + ? ^ $ { } [ ] ( ) | \ /
Why am I only getting one match?
Enable the Global (g) flag to find all matches instead of stopping at the first one. By default, JavaScript regex stops after finding the first match. The global flag tells the engine to continue searching through the entire input string and return every occurrence that matches your pattern.
U

Reviewed by the UtilHQ Team

Our tools are verified for accuracy. Results are estimates for planning purposes.