~/tools/regex-tester
Regex Tester
Write and test regular expressions instantly — matches highlighted in real-time. Zero server calls, zero data sent.
What is a Regular Expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. They are used to match, search, replace, and validate strings in text. Regex is supported natively in JavaScript, Python, Java, Go, and virtually every programming language. Mastering regex dramatically speeds up string processing tasks.
Common Patterns
Rather than memorizing the full regex syntax upfront, most real-world tasks can be solved by combining a small set of recurring building blocks. The patterns below cover the vast majority of day-to-day use cases — from extracting numbers and words to matching boundaries and whitespace. Once these become second nature, you can compose them to handle increasingly complex patterns.
Flags
A regex pattern on its own only matches exactly what it describes. Flags change how the entire expression behaves — whether matching is case-sensitive, whether it finds all occurrences or just the first, and how line boundaries are interpreted. Using the wrong flag (or forgetting the g flag when you expect multiple results) is one of the most common sources of subtle regex bugs.
/gglobalFind all matches, not just the first
/iinsensitiveCase-insensitive matching
/mmultiline^ and $ match line boundaries
/sdotAll. matches newline characters too
Quantifiers
Quantifiers control how many times the preceding token must appear for a match to succeed. The distinction between greedy and lazy matching is especially important: greedy quantifiers consume as much input as possible, which can cause a pattern to match far more than you intend — a classic pitfall when parsing HTML or extracting content between delimiters. Adding ? after any quantifier switches it to lazy mode, matching as little as possible instead.
Groups & Anchors
Groups and anchors are what elevate regex from simple pattern matching to a structured data extraction tool. Capturing groups let you isolate specific parts of a match — pulling just the domain from an email address, or the version number from a release string — while anchors constrain where in the input a match is allowed to occur. Lookaheads and lookbehinds take this further, letting you write conditions like "followed by" or "preceded by" without those surrounding characters becoming part of the match result.
Real-World Regex Examples
The fastest way to internalize regex is through practical examples that map to problems you've already encountered. The patterns below cover recurring validation and extraction tasks in web development, scripting, and data processing — email validation, IP addresses, URL parsing, date formats, and more. Each one can be copied directly into the tester above and modified to fit your specific requirements.