Copynix

Regular Expression Tester and Debugger Online

//g

Frequently Asked Questions

What is a regular expression?

A regular expression (regex) is a sequence of characters that defines a search pattern. It is used for string matching, validation, and text manipulation in virtually all programming languages.

What regex flavor does this tool use?

This tool uses JavaScript's built-in RegExp engine, which follows the ECMAScript specification. Most common regex syntax works the same across languages, but advanced features may differ.

What are capture groups in regex?

Capture groups (parentheses) allow you to extract specific parts of a match. For example, /(\d{4})-(\d{2})-(\d{2})/ captures year, month, and day separately from a date string.

What are common regex flags?

g (global): find all matches. i (case-insensitive): ignore letter case. m (multiline): ^ and $ match line boundaries. s (dotAll): dot matches newlines.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +, ?) match as much as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, given '<b>text</b>', the greedy <.*> matches the whole string, while the lazy <.*?> matches only '<b>'.

Does JavaScript regex support lookahead and lookbehind?

Yes. Positive lookahead (?=...) and negative lookahead (?!...) are supported in all browsers. Positive lookbehind (?<=...) and negative lookbehind (?<!...) are supported in all modern browsers (Chrome 62+, Firefox 78+, Safari 16.4+).

How do I match a literal dot or parenthesis in regex?

Special characters must be escaped with a backslash. To match a literal dot use \., a literal parenthesis use \( and \), a literal backslash use \\. For example, to match '3.14', use the pattern 3\.14 instead of 3.14 (which would also match '3X14').

Regular expressions are a powerful pattern-matching language used in every programming language for validation, search, and text transformation. This tester gives you a live feedback loop β€” type your pattern and see matches highlighted instantly.

How to use

  1. 1

    Enter your regex pattern

    Type your regular expression into the pattern field. Do not include the opening and closing slashes β€” just the pattern itself. Add flags (g, i, m, s) using the flag toggle buttons.

  2. 2

    Paste your test string

    Enter the text you want to test against in the test string field. Matches are highlighted in the text as you type, giving instant visual feedback.

  3. 3

    Read the match details

    The results panel shows the total number of matches, each matched substring, the position (index) of each match, and the contents of any capture groups.

  4. 4

    Use flags to refine matching

    Toggle 'g' to find all matches (not just the first), 'i' for case-insensitive matching, 'm' to make ^ and $ match line boundaries instead of the full string, and 's' to make . match newlines.

Use cases

  • Validate input formats

    Build and test patterns for validating email addresses, phone numbers, postal codes, dates, IP addresses, and credit card numbers before implementing them in your code.

  • Extract data from text

    Use capture groups to extract specific parts of log lines, CSV rows, or structured text. Test your extraction pattern here before deploying it to a script or database query.

  • Build text search and replace

    Test search patterns for code refactoring, log analysis, or find-and-replace operations in your editor. The live highlighting shows exactly which text your pattern will match.

Related Tools

Text Diff

Compare two texts

JSON

Format & minify JSON

URL Encode

URL encode & decode

HTML Entities

HTML encode & preview

Regular expressions are a pattern language for describing text structures, available in virtually every programming language and text editor. A regex like \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b describes an email address; (\d{4})-(\d{2})-(\d{2}) matches an ISO date and captures year, month, and day in separate groups. Mastering regex removes the need for brittle string manipulation code in parsing, validation, search, and transformation tasks.

This tester evaluates your regular expression against sample text in real time, highlighting every match and displaying captured groups so you can see exactly what each part of your pattern matches. Toggle the standard flags β€” global (g), case-insensitive (i), multiline (m), and dotAll (s) β€” to understand how they affect matching behavior. All evaluation runs in your browser's JavaScript engine; no input leaves your device.