AbraCalc

Find and Replace with Regex

Find and replace text using full regular-expression patterns with flags. Supports global, case-insensitive, and multiline modes. Runs in your browser.

Pure browser JavaScript (native RegExp) — no libraries required.

Embed this tool on your site
Cite this tool

APA

AbraCalc. (2026). Find and Replace with Regex [Online calculator]. Retrieved from https://abracalc.com/app/find-and-replace-regex/

BibTeX

@misc{abracalc-find-and-replace-regex, author = {AbraCalc}, title = {Find and Replace with Regex}, year = {2026}, howpublished = {\url{https://abracalc.com/app/find-and-replace-regex/}} }

Did this tool answer your question?

How to use this tool

  1. Paste your text.
  2. Enter a regex pattern in Find and a replacement in Replace with.
  3. Toggle flags and click Replace.

Find and replace text using full regular-expression patterns with flags. Supports global, case-insensitive, and multiline modes. Runs in your browser.

How it works

The Find and Replace with Regex tool lets you run powerful pattern-based search and replace operations on any text without leaving your browser. Paste your text into the input panel, enter a regular expression in the Find field and a replacement string in the Replace field, then click Replace to see the transformed result instantly.

Supported flags include: g (global, replace all matches rather than just the first), i (case-insensitive matching), and m (multiline, so ^ and $ match the start and end of each line). Flags can be combined freely. The replacement string supports capture group references such as $1, $2, allowing you to rearrange matched parts.

Matches are highlighted in the preview so you can verify what will be changed before committing. This is ideal for reformatting data exports, cleaning up copied text, transforming log files, or making bulk edits to code snippets.

The tool runs entirely in your browser using JavaScript's built-in RegExp engine, so no text is uploaded and results are instant even for large inputs.

Worked examples

Remove all HTML tags from copied web content

  1. Paste the HTML-laden text into the input panel.
  2. Enter '<[^>]+>' in the Find field.
  3. Leave the Replace field empty.
  4. Enable the 'g' (global) flag.
  5. Click Replace — all tags are stripped, leaving plain text.

Clean plain text with all HTML tags removed.

Reformat dates from MM/DD/YYYY to YYYY-MM-DD

  1. Paste a list of dates in MM/DD/YYYY format.
  2. Enter '(\d{2})/(\d{2})/(\d{4})' in the Find field.
  3. Enter '$3-$1-$2' in the Replace field.
  4. Enable the 'g' flag and click Replace.

All dates reformatted to ISO 8601 (YYYY-MM-DD) order.

Common mistakes to avoid

  • Forgetting to enable the 'g' flag and being surprised that only the first occurrence is replaced.
  • Using '.' assuming it matches only a period — in regex, '.' matches any character except a newline; use '\.' to match a literal dot.
  • Writing backreferences as '\1' instead of '$1' in the replacement field — JavaScript replacement strings use '$1', '$2', not backslash notation.

Key terms

Regular expression (regex)
A sequence of characters that defines a search pattern, allowing flexible matching of strings, digits, whitespace, and more.
Capture group
A portion of a regex enclosed in parentheses '()' whose matched text is saved and can be referenced in the replacement as $1, $2, etc.
Flag
A modifier applied to a regex that changes matching behavior, such as 'g' for global replacement or 'i' for case-insensitive matching.

Frequently asked questions

Do I need to escape special characters?
Yes — regex metacharacters like . * + ? ( ) [ ] { } \ | ^ $ must be escaped with a backslash if you want them literally.

References & sources