What is a Regular Expression?
A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regex is used in programming to match, search, and manipulate strings. It's supported natively in virtually every programming language including JavaScript, Python, Java, PHP, Ruby, and more.
Regex is one of the most powerful tools in a developer's toolkit — but also notoriously hard to write correctly without testing. That's why a live regex tester like this one is invaluable during development.
Regex Flags Explained
- g (global) — Find all matches instead of stopping at the first one
- i (case-insensitive) — Match regardless of uppercase or lowercase
- m (multiline) — Makes ^ and $ match start/end of each line, not just the whole string
- s (dotAll) — Makes . match newline characters too
Common Regex Patterns
- Email:
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
- URL:
https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}
- Phone (US):
(\+1)?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}
- IPv4:
(\d{1,3}\.){3}\d{1,3}
- Hex color:
#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})
Frequently Asked Questions
Which regex flavor does this tester use? ▼
This tester uses JavaScript's built-in RegExp engine, which follows the ECMAScript regex standard. This is the same regex used in Node.js, Chrome, Firefox, and all modern browsers.
What are capture groups in regex? ▼
Capture groups are defined by parentheses in your regex pattern. They let you extract specific parts of a match. For example, the pattern (\d{4})-(\d{2})-(\d{2}) on "2026-04-23" would capture "2026", "04", and "23" as three separate groups.
Why is my regex not matching anything? ▼
Common reasons: (1) Missing the 'g' flag when expecting multiple matches, (2) Incorrect escaping — special characters like . * + ? need a backslash prefix, (3) Case mismatch — add the 'i' flag for case-insensitive matching, (4) Anchors (^ and $) preventing matches on partial strings.