📋 In This Page
What Is a Regular Expression?
A regular expression (regex) is a sequence of characters forming a search pattern, used to match, locate, and manipulate text. It's one of the most powerful tools in a developer's toolkit — used for form validation, data extraction, search-and-replace, and parsing structured text across virtually every programming language.
This tool uses the native JavaScript RegExp engine — the same engine that runs in every browser and Node.js application. Patterns you build here work identically in JavaScript code.
Understanding Regex Flags
| Flag | Name | Effect |
|---|---|---|
| g | Global | Find all matches, not just the first one |
| i | Ignore Case | Match regardless of upper/lower case |
| m | Multiline | ^ and $ match start/end of each line, not whole string |
| s | Dot All | . matches newline characters too (normally it doesn't) |
| u | Unicode | Enables full Unicode matching, including surrogate pairs |
Common Regex Patterns Reference
| Pattern | Matches | Use Case |
|---|---|---|
| ^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$ | Email address | Form validation |
| ^[6-9]\d{9}$ | Indian mobile number | Phone validation |
| ^[A-Z]{5}\d{4}[A-Z]$ | PAN card number | Indian KYC forms |
| ^\d{6}$ | Indian PIN code | Address forms |
| ^https?:\/\/.+$ | URL | Link validation |
| ^#[0-9A-Fa-f]{6}$ | Hex color code | Color picker input |
| ^(\d{1,3}\.){3}\d{1,3}$ | IPv4 address | Network config validation |
💡Click the Quick patterns buttons above the editor to load these directly into the tester with matching sample text.
Frequently Asked Questions
A regex is a sequence of characters defining a search pattern, used for string matching, validation, search-and-replace, and text parsing. Common uses include validating emails and phone numbers, extracting data, and find-replace in code editors.
g finds all matches. i ignores case. m makes ^ and $ match start/end of each line instead of the whole string. s makes . match newlines too. Flags combine, e.g. 'gi' for global case-insensitive matching.
Capture groups, in parentheses (), extract specific parts of a match. (\d{3})-(\d{4}) on '555-1234' captures '555' as group 1 and '1234' as group 2. Named groups use (?<name>...) syntax for readable extraction.
A practical pattern: ^[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}$. This matches most common formats. Fully RFC-5322 compliant validation is extremely complex — combine basic regex with an actual verification email for production use.
For 10-digit mobile numbers starting 6-9: ^[6-9]\d{9}$. With optional +91: ^(\+91[\-\s]?)?[6-9]\d{9}$. This validates format only, not whether the number is active.
Greedy quantifiers (*, +, {n,m}) match as much as possible. Lazy quantifiers (*?, +?) match as little as possible. On '<a><b>', <.*> greedily matches the whole string, while <.*?> lazily matches just '<a>'.
This tool uses the native JavaScript RegExp engine — the same one used in browsers and Node.js. It supports standard syntax including character classes, quantifiers, anchors, lookaheads, lookbehinds, and named capture groups.
More Free Developer Tools
📅 June 2026 · Written by the ToolLoom Team · Reviewed for accuracy June 2026
About ToolLoom: Uses native JavaScript RegExp engine — no external regex libraries. All processing runs locally in your browser. Found an error? Email contact@toolloom.in
About ToolLoom: Uses native JavaScript RegExp engine — no external regex libraries. All processing runs locally in your browser. Found an error? Email contact@toolloom.in