JavaScript String.replace patterns: $1, $&, $`, $', and $$.
How to Test Regular Expressions Online
- 1
Enter your regex pattern
Type or paste your regular expression into the pattern field. The tool accepts any valid JavaScript regex syntax including character classes, quantifiers, groups, and lookaround assertions. - 2
Set JavaScript regex flags
Toggle g (all matches), i (ignore case), m (^ and $ at line ends), s (dot matches newline), u (Unicode), and y (sticky at lastIndex). - 3
Add a test string
Paste text to test. You can add more than one string. Matches highlight as you type. - 4
Preview replace with $1
Enter a replacement such as $1. The preview uses JavaScript String.replace. Load sample uses pattern (\w+), replace $1, and the string hello world.
Common Use Cases
Email Validation
Data Extraction
Search and Replace
Log Parsing
Why use our Regex Tester?
This page tests JavaScript regular expressions in your browser. Matches highlight as you type. Capture groups show as $1, $2, and so on. The Replace field runs JavaScript String.replace, so $1, $&, $`, and $' work the same as in your code.
Supported flags are g, i, m, s, u, and y. The u flag enables Unicode property escapes. The y flag is sticky and matches only at lastIndex. Other languages share much of this syntax, but this tool does not emulate Python, PCRE, or Go engines.
Use the sample path to confirm replace: pattern (\w+), replace $1, test string hello world. Pair this tool with the Glob Pattern Tester for file paths, or the Diff Checker to compare text after a replace. Processing stays in this browser. The page does not upload your test strings.
How It Compares
This tester uses the JavaScript regex engine in your browser. Your pattern and test strings stay in this tab. The page does not upload them. Other sites may offer extra engines or a pattern library. This page focuses on JavaScript match, flags, and String.replace with $1.