Frequently Asked Questions
What are regex flags?
Flags modify how the regex engine searches: g (global) finds all matches instead of stopping at first; i (case insensitive) matches regardless of letter case; m (multiline) makes ^ and $ match line start/end instead of string start/end; s (dotAll) makes . match newlines too.
How do I capture groups in regex?
Use parentheses to create capture groups: (\d{4}) captures a 4-digit sequence. In the match details below, you'll see Group 1, Group 2, etc. for each captured group in each match.
What does \b mean in regex?
\b is a word boundary anchor. It matches the position between a word character (\w) and a non-word character. \b\w+\b matches complete words. Without \b, patterns can match partial words.
Is my test data sent to a server?
No, pattern matching runs entirely in your browser using JavaScript's built-in regex engine. Your test string and pattern never leave your device.
Does this tool use the same regex engine as JavaScript?
Yes, matches are tested using the browser's native JavaScript RegExp engine, so results will match exactly what you'd get running the same pattern in JavaScript code.
Why isn't my pattern matching anything?
Common causes include a missing global flag (g) when expecting multiple matches, special characters that need escaping (like . or *), or case sensitivity — try adding the "i" flag if case shouldn't matter.
About the Regex Tester Tool
The Logrith Regex Tester lets you build, test, and debug regular expressions against sample text in real time, showing every match, capture group, and flag effect instantly as you type. Regular expressions are a powerful but notoriously tricky syntax to get right on the first try, and this tool removes the guesswork by showing exactly what a pattern matches before you use it in actual code.
A regular expression (regex) is a sequence of characters that defines a search pattern, used for finding, validating, or extracting text that matches specific rules — email addresses, phone numbers, dates, or any custom text format. Writing regex correctly on the first attempt is difficult even for experienced developers, since small syntax differences can completely change what a pattern matches. Testing interactively, rather than running code repeatedly, is by far the fastest way to get a pattern right.
Understanding Regex Flags
- g (global) — finds every match in the text instead of stopping after the first one found.
- i (case insensitive) — matches letters regardless of uppercase or lowercase, so "Hello" and "hello" are treated the same.
- m (multiline) — changes how ^ and $ behave, making them match the start and end of each line rather than only the start and end of the entire string.
- s (dotAll) — makes the . (dot) wildcard also match newline characters, which it doesn't by default.
Common Regex Patterns and What They Do
- \d matches any digit (0-9), while \D matches any non-digit character.
- \w matches any word character (letters, digits, underscore), while \W matches anything that isn't.
- \s matches whitespace (spaces, tabs, newlines), while \S matches non-whitespace.
- + means "one or more" of the preceding element, while * means "zero or more".
- ? makes the preceding element optional (zero or one occurrence).
- {n} requires exactly n repetitions, while {n,m} requires between n and m repetitions.
- ^ and $ anchor a match to the start and end of the string (or line, with the m flag).
Understanding Capture Groups
Parentheses in a regex pattern create a capture group, which extracts a specific portion of each match rather than just confirming that a match occurred. For example, the pattern (\d{4})-(\d{2})-(\d{2}) matching a date like "2024-03-15" would capture "2024" as Group 1, "03" as Group 2, and "15" as Group 3 — letting you pull out the year, month, and day separately rather than just the full matched string. This tool displays every capture group for every match, making it easy to confirm your groups are extracting exactly the parts of the text you intend to use.
Common Use Cases for Regex
- Form validation — checking that an email address, phone number, or postal code matches an expected format before accepting it.
- Data extraction — pulling specific pieces of information, like dates or prices, out of larger blocks of unstructured text.
- Find and replace — searching for a pattern across a codebase or document and replacing every occurrence with a different format.
- Log file analysis — filtering server or application logs for lines matching a specific error pattern or timestamp format.
- Input sanitization — identifying and stripping unwanted characters from user-submitted text before processing it further.
Step-by-Step: How to Test a Regex Pattern
Privacy
All pattern testing happens locally in your browser using JavaScript's built-in regular expression engine — your test text and pattern are never sent to a server or logged anywhere. This makes the tool safe to use even when testing patterns against sensitive sample data like real user information or internal log excerpts.
Tips for Debugging a Pattern That Isn't Working
When a regex doesn't match what you expect, work through it step by step rather than guessing at the whole pattern at once. Start by simplifying the pattern down to its smallest matching piece and confirm that works, then add complexity back one piece at a time, checking after each addition. Pay close attention to characters that have special meaning in regex — a period (.) matches any character unless escaped as \., and parentheses, brackets, and braces all carry structural meaning rather than being literal characters. Forgetting the global flag is one of the most common reasons a pattern only seems to match once when multiple matches were expected, so if you're only seeing one result where you expected several, that's usually the first thing to check.