Enter pattern without slashes
g: global · i: ignore case · m: multiline · s: dotAll · u: unicode · y: sticky
A regex tester is an interactive tool that allows developers and technical professionals to write, test, and debug regular expressions in real time. Regular expressions (often abbreviated as regex, regexp, or RE) are sequences of characters that define a search pattern. They are used to match, find, replace, and validate text strings across virtually every modern programming language, text editor, and development tool. This regex tester uses the JavaScript (ECMAScript) regex engine, which powers modern web browsers and Node.js. By testing your patterns against sample text instantly, you can refine your regex logic without the overhead of writing and running separate code. The tool displays all matches, their positions, and any capture groups extracted from the test string, helping you verify correctness before using patterns in production code.
Enter your regular expression pattern in the "Regular Expression Pattern" field without slashes. For example, to match email addresses, you might use^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. Next, select any flags you need from the checkboxes: global (g) to find all matches, ignore case (i) for case-insensitive matching, multiline (m) to treat line breaks as boundaries, dotAll (s) to match newlines with the dot operator, unicode (u) for Unicode pattern matching, and sticky (y) for anchored matches. Then paste or type your test string into the "Test String" textarea. The tool will instantly build a regex object, execute it against your test string, and display all matches with their indices, capture groups, and highlighted sections in the original string. If your pattern is invalid, an error message will appear explaining the syntax problem.
Regular expressions use a concise syntax to describe patterns. Here are the most frequently used tokens:
. — Matches any single character except newline (or any character if s flag is used). Example: a.c matches "abc" and "adc".\d — Matches any digit (0–9). Example: \d{3}-\d{4} matches "123-4567".\w — Matches any word character (letters, digits, underscore). Example: \w+ matches "hello_world123".\s — Matches any whitespace character (space, tab, newline). Example: \s+ matches one or more spaces.^ — Anchors to the start of the string (or line in multiline mode). Example: ^hello matches "hello" only at the beginning.$ — Anchors to the end of the string (or line in multiline mode). Example: world$ matches "world" only at the end.+ — Matches one or more of the preceding element. Example: a+ matches "a", "aa", "aaa", and so on.* — Matches zero or more of the preceding element. Example: ab*c matches "ac", "abc", "abbc".? — Matches zero or one of the preceding element (makes it optional). Example: colou?r matches "color" and "colour".[abc] — Character class: matches any one character in the set. Example: [aeiou] matches any vowel.[^abc] — Negated character class: matches any character NOT in the set. Example: [^0-9] matches any non-digit.(abc) — Capture group: groups characters and captures the match. Example: (\w+)@(\w+) captures the user and domain from an email.| — Alternation: matches either the left or right pattern. Example: cat|dog matches "cat" or "dog".\ — Escape character: escapes special characters to match them literally. Example: \. matches a literal period instead of any character.Regex flags modify how the pattern matching behaves. The global flag (g)causes the regex engine to find all matches in the string instead of stopping after the first match. The ignore case flag (i) makes matching case-insensitive, so "A" and "a" are treated identically. The multiline flag (m) treats ^ and $ as line boundaries rather than string boundaries, useful when working with multi-line text. The dotAll flag (s) allows the dot (.) to match newline characters, which it normally does not. The unicode flag (u)enables Unicode pattern matching, crucial for handling emoji and international characters correctly. The sticky flag (y) makes the regex match only at the position indicated by its lastIndex property, anchoring subsequent matches.
This tool uses the JavaScript (ECMAScript) regex engine, which is the standard for browsers and Node.js. For comprehensive documentation, see the MDN Regular Expressions guide. Keep in mind that other languages (Python, Java, Perl) have slightly different syntax and features.
A capture group is a portion of the regex pattern enclosed in parentheses(). It extracts and remembers the matched text. For example, in the pattern(\w+)@(\w+), there are two capture groups: one for the username and one for the domain. When the regex matches "john@example", Group 1 contains "john" and Group 2 contains "example". Capture groups are displayed in the results of this tool.
Special regex characters (like . * + ? [ ] ( ) ^ $ |) have special meaning in patterns. To match them literally, escape them with a backslash\. For example, \.matches a literal period, \(matches a literal parenthesis, and \\matches a literal backslash.