Understanding Regular Expressions (Regex)
A regular expression is a specialized sequence of characters defining a search pattern. Commonly utilized in algorithms for string searching, input sanitization, lexical parsing, and text transformations, regular expressions provide high-speed validation for complex strings like email addresses, URLs, IP addresses, and dates.
Capture Groups & Tokens
Parentheses (...) establish sub-patterns known as capture groups. This permits parsing individual sections of matched strings (such as domain extensions or phone area codes) directly into discrete variables.
Execution Modifiers (Flags)
Flags alter the parsing behavior of regular expressions. Setting the global flag (g) ensures the engine matches all occurrences rather than halting at the first, while m adjusts anchor points to match per line.
Common Regex Metacharacters & Tokens
| Token | Description | Example Match |
|---|---|---|
| \d | Matches any single digit (equivalent to [0-9]) | "5" in "Room 5" |
| \w | Matches any alphanumeric character or underscore ([a-zA-Z0-9_]) | "a", "9", "_" |
| \s | Matches any whitespace character (space, tab, newline) | " " or "\t" |
| ^ and $ | Anchors matching to the start (^) and end ($) of the string or line | ^Hello$ |
| + and * | Quantifiers: (+) matches 1 or more times; (*) matches 0 or more times | a+ matches "aaa" |
Frequently Asked Questions
Which regex flavor does this online tester use?
This tool executes directly within your browser using JavaScript's native RegExp engine (ECMAScript flavor), supporting modern features like named capture groups, lookaheads, and lookbehinds.
What do the regex flags (g, i, m, s) do?
g finds all matches instead of stopping after the first; i ignores case sensitivity; m treats start (^) and end ($) anchors across each line; and s (dotAll) allows the dot (.) to match newline characters.
Is my test data or pattern sent to any backend server?
No. All regular expression parsing, execution, and DOM highlighting happen 100% locally in your browser's JavaScript engine. No data ever leaves your computer.