Answers to the most common questions about regular expressions,
regex flags, pattern syntax, and how to use this tool.
What is regex?
Regex, short for regular expression, is a pattern language used to search, match, validate, or extract text. Developers use regex for form validation, log parsing, data cleaning, and pattern extraction in JavaScript, Python, Java, and most modern programming languages.
What is a regex tester?
A regex tester is a browser tool that lets you write a regular expression, paste sample text, and see exactly which parts match — with highlighted results, match indexes, and captured group values. It helps you debug and refine patterns before using them in production code.
How do I test regex online?
Type a regex pattern into the Pattern field, choose the flags you need, paste sample text, and run the test. This tool shows highlighted matches in your text, individual match items with index positions, capture group values, and a live replacement preview — all in the browser.
How do regex flags work?
Flags change how a pattern behaves. g finds all matches globally, i makes matching case-insensitive, m changes start and end anchors to work per line, s allows dots to match newlines, u enables Unicode mode, and y enables sticky matching from a specific position.
Why is my regex invalid?
A regex becomes invalid due to unbalanced parentheses, malformed character classes, invalid escape sequences, or syntax not supported by the JavaScript RegExp engine. This tester catches those errors with try/catch and displays exactly what needs fixing.
Is this tool safe to use?
Yes. All regex testing runs entirely in your browser using the JavaScript RegExp engine. No pattern or text data is transmitted to any server. It is completely safe to test patterns on sensitive or proprietary content.
Can I use this for JavaScript regex?
Yes. This tester is built around the JavaScript RegExp engine, so results reflect exactly what you would see in frontend JavaScript, Node.js, and modern JavaScript runtimes — including String.prototype.match(), replace(), replaceAll(), and split().
What is a capture group?
A capture group is a section of a regex wrapped in parentheses. It extracts a specific portion of a match, such as a year from a date or a domain from a URL. In JavaScript, captured groups appear at index 1, 2, and so on in the match result array.
What does .* mean in regex?
In regex, . matches any single character except a newline, and * means zero or more of the preceding token. Together, .* greedily matches any sequence of characters on a single line, including an empty string. Enabling the s (dotAll) flag extends . to also match newlines.
What do ^ and $ mean in regex?
^ is the start anchor and $ is the end anchor. ^Hello matches 'Hello' only at the very start of the string. world$ matches 'world' only at the end. With the m (multiline) flag, both anchors match the start and end of each individual line.
How do I match an email address with regex?
A practical pattern for testing email-like strings is [\w.+-]+@[\w-]+\.[a-zA-Z]{2,}. For production use, dedicated validation libraries are more reliable, since the full RFC 5321 email specification is too complex to capture completely in a single regex pattern.
Why is my regex not matching anything?
Common causes: the g flag is missing when expecting multiple results, anchors (^ or $) are too restrictive, special characters like . or + need escaping for literal matches, or the pattern contains whitespace or encoding that does not match the actual input text.
Can regex be used for find and replace?
Yes. In JavaScript, String.prototype.replace() and replaceAll() accept regex as the first argument. Capture groups can be referenced in the replacement string with $1, $2, and so on. This tester shows a live replace preview so you can confirm the output before using it in code.
Is regex case sensitive?
Yes, regex is case sensitive by default. The pattern /hello/ will not match 'Hello' or 'HELLO'. Adding the i flag disables case sensitivity so /hello/i matches any capitalization of the word.
What is the difference between + and * in regex?
+ means one or more occurrences of the preceding token. * means zero or more. So \d+ requires at least one digit while \d* allows a match even when there are zero digits. Both are greedy by default and match as many characters as possible.
What is a lookahead in regex?
A positive lookahead (?=...) checks whether a pattern follows the current position without consuming those characters in the match. For example, \w+(?=@) matches a word only if immediately followed by @, but the @ itself is not included in the matched text.
How do I match exactly n characters?
Use a quantifier with braces: {n} matches exactly n occurrences. \d{4} matches exactly four digits. \w{3,8} matches between three and eight word characters. {n,} means at least n occurrences and {,n} means at most n.
Can I test regex on multiline text?
Yes. Paste multiline text directly into the sample text area. Use the m flag so ^ and $ match each individual line. Use the s flag (dotAll) if you want . to match newline characters so patterns can span across line boundaries.