Text & String Utilities100% Client-Side

Replace Text Using a Regular Expression

Paste a block and enter a regular expression to find the parts you want to change. Set a replacement string to insert at each selected match. Capture references let you reuse pieces of the matched text, such as fields on either side of a separator. The result preserves the rest of the source, so you can review the full edit before copying it back.

Configuration Options
Input
16 chars•1 lines
Output

How to Use the Find and Replace with Regex Online

  1. 1Paste the text to edit, including any spaces and line breaks relevant to the pattern.
  2. 2Enter the regular expression and set its flags separately.
  3. 3Enter the replacement text or leave it empty to delete the matches.
  4. 4Inspect the result for unintended matches, especially around punctuation or line endings.

Input & Output Examples

The global flag replaces each run of two or more spaces with one space.

Input Sample
a  b    c
Expected Output
a b c

The replacement puts the second capture before the first, reordering the values in both matches.

Input Sample
west=12, east=7
Expected Output
12:west, 7:east

Practical Developer Workflows

  • Normalize the separator inside repeated fixture labels while keeping their numeric part.
  • Condense repeated spaces in a pasted text sample.
  • Swap two captured fields in a simple list of delimiter-separated values.

Zero Server Uploads & Complete Privacy

Runs 100% in your browser; no data is uploaded to any server.

Notice a bug, calculation error, or outdated info?

Let us know directly so our engineering team can fix it.

Frequently Asked Questions

Keep the global flag g to apply the replacement to all matches. Without that flag, a regular expression normally replaces only its first match. Combine g with i when the search should also ignore case.

Explore Other Tools

12 suggested tools

View all tools