Regex Find and Replace Online
Transform text with regular expressions, optional flags, and capture groups such as $1.
▣ Processed locally in your browser. Nothing is uploaded.
Changed text
Invalid patterns are reported before anything changes.
What is regex find and replace?
A regular expression describes a text pattern rather than one exact phrase. It can find groups of digits, repeated whitespace, line beginnings, or structured identifiers. TextUnicorn uses the regular-expression syntax built into JavaScript.
Simple regex patterns
| Pattern | Matches |
|---|---|
\d+ | One or more digits |
\s+ | One or more whitespace characters |
\w+ | A run of word characters in JavaScript regex syntax |
^Note: | “Note:” at the beginning of input, or of each line with multiline mode |
Capture groups and replacements
Parentheses capture part of a match. The replacement can reuse captured text with $1, $2, and so on.
Pattern: Order (\d+) Replacement: ID-$1 Input: Order 123 Output: ID-123
Flags: g, i, and m
- g — Global: replace all matches rather than only the first.
- i — Ignore case: match uppercase and lowercase forms.
- m — Multiline: make
^and$work at the start and end of individual lines.
Practical examples
Normalize repeated whitespace
Pattern: \s+ Replacement: a single space
Reformat IDs
Pattern: ITEM-(\d+) Replacement: Product $1
Change ISO-style dates
Pattern: (\d{4})-(\d{2})-(\d{2})
Replacement: $3.$2.$1Test date expressions with your real formats: regular expressions match text patterns but do not validate whether a date actually exists.
When to use the simpler tool
If you only need to replace one known word or phrase, Find & Replace is easier and reduces the chance of an overly broad match. Use regex when the varying structure itself is what you need to find.
Frequently asked questions
What regex syntax does TextUnicorn use?
It uses the regular-expression implementation available in your JavaScript-capable browser.
What does $1 mean?
It inserts the text captured by the first pair of parentheses in the pattern.
Can an invalid regex damage my text?
The tool reports invalid expressions before producing a replacement. Keep a copy of important source text and test broad patterns on a small sample first.
Is regex processing local?
Yes. The pattern and text are processed in your browser.