How to use the Regex Find & Replace
Use regex for powerful pattern-based replacements in five steps:
1
Paste your text
Paste the text to transform into the input area, or upload a file.
2
Enter a regex pattern
Type a JavaScript regex pattern in the pattern field (without slashes). Use capture groups like (\w+) to capture parts of the match.
3
Enter the replacement
Type the replacement string. Use $1, $2, $3 to reference capture groups. Leave empty to delete all matches.
4
Set flags and preview
Toggle regex flags (g, i, m, s, u) and enable 'Preview matches' to see all matches highlighted in violet. Syntax errors show instantly below the pattern field.
5
Click Replace All
Apply the replacement to all matches. Stats pills show the total replacement count and the full pattern with flags.
When to use this tool
Use for pattern-based text transformations that plain find/replace cannot handle:
- →Reformatting dates from MM/DD/YYYY to YYYY-MM-DD (or any other format) using capture groups and backreferences
- →Redacting sensitive data like email addresses, phone numbers, or credit card numbers matching a pattern
- →Extracting and restructuring repeated data patterns across hundreds of lines in one operation
- →Replacing variable-length whitespace runs, multiple consecutive punctuation marks, or other pattern-based noise
- →Transforming structured text formats — converting CSV rows, log lines, or config entries to a different structure
- →Normalising inconsistent formatting across a dataset, such as capitalising the first letter of every sentence
Frequently asked questions
Q:What regex flags are supported?
All five standard JavaScript regex flags are supported: g (global — match all occurrences, not just the first), i (case insensitive — match regardless of letter case), m (multiline — make ^ and $ match the start and end of each line rather than the whole string), s (dotAll — make the dot . match newline characters as well as all other characters), and u (Unicode — enable full Unicode matching and proper handling of supplementary characters).
Q:How do I use capture groups and backreferences?
Wrap parts of your pattern in parentheses to create capture groups: for example, (\d{4})-(\d{2})-(\d{2}) creates three groups. Reference them in the replacement string using $1, $2, $3 in order. To reformat a date from YYYY-MM-DD to DD/MM/YYYY, use pattern (\d{4})-(\d{2})-(\d{2}) and replacement $3/$2/$1. The entire match is available as $& if you need to reference it without capturing.
Q:What happens if my regex pattern has a syntax error?
An error message appears in red immediately below the pattern field as you type, showing the exact JavaScript error from attempting to compile the regex. The Replace All button is disabled while the pattern contains a syntax error, so you cannot accidentally apply a broken replacement. Common syntax errors include unmatched parentheses, invalid quantifiers, and invalid escape sequences.
Q:How is the pattern input formatted?
The pattern field is styled as /pattern/flags — the tool displays a leading / and a trailing /flags suffix (showing your active flags) around the input box, exactly matching the JavaScript regex literal notation. You type only the pattern body — no surrounding slashes are needed. The flags shown after the closing / update in real time as you toggle them.
Q:Can I replace across multiple lines with regex?
Yes — enable the m (multiline) flag to make ^ and $ match the start and end of each individual line. Enable the s (dotAll) flag to make the dot (.) match newline characters, which allows patterns to span multiple lines. Without the s flag, the dot matches any character except newlines, which is the default JavaScript regex behaviour.
Q:How is this different from the plain Text Find & Replace tool?
Text Find & Replace treats the search term as a literal string — characters like ., *, +, (, and [ have no special meaning. Regex Find & Replace interprets the pattern as a JavaScript regular expression where those characters are metacharacters. Use the plain tool for simple word or phrase substitutions; use the regex tool when you need pattern matching, capture groups, quantifiers, character classes, or any other regex feature.