Find and Replace: plain text or regex, with several rules

Rules

Run from top to bottom, each on the output of the one before.

    About Find and Replace

    This tool finds text and replaces it. Paste your text into the Source box, type what to find and what to put instead, and the Result box updates as you type. Matches are highlighted in the source and each rule shows how many it found.

    Search for plain text, or switch a rule to Regex for patterns with flags and capture groups. Whole word, ignore case and all matches are options on every rule. Add more rules to run several replacements in order, reorder them, or switch one off without deleting it.

    Everything runs in your browser. Your text is not sent anywhere.

    How to find and replace text

    1. Paste or type your text into the Source box.
    2. Type what to find and what to replace it with. Tick Regex for patterns, and add rules for more replacements.
    3. Check the Result, then copy it or download it as a .txt file.

    Frequently asked questions

    How do I replace text with a regular expression?

    Tick Regex on a rule, type the pattern in Find and the new text in Replace with. In the replacement, $1, $2 and so on insert numbered capture groups, $<name> inserts a named group, $& inserts the whole match and $$ writes a literal dollar sign. \n and \t in the replacement become a line break and a tab.

    What does Whole word do?

    It only matches when the match is not touching a letter, digit or underscore on either side, so cat matches in the cat sat but not in category. It works in plain and regex mode, and also for words that start or end with a symbol, such as c++.

    How do several rules work together?

    Rules run from top to bottom, and each one works on the output of the one before it. Move a rule up or down with the arrow buttons, switch it off with its checkbox to skip it, or remove it. The highlights in the source show the first active rule, because the later rules run on text that has already changed.

    How do I undo a replacement?

    The Result box shows the outcome without touching your source. Apply result to source moves it into the source box so you can run more rules on it, and Undo to original puts back the text you had before the first apply. Typing in the source starts fresh.

    Why does it say a rule took too long?

    Some patterns, such as (a+)+$ tested against a long run of a's followed by another character, backtrack an enormous number of times. The rules run in a background worker that is stopped after three seconds, so the page keeps working. Rewrite the pattern to avoid nested quantifiers over the same characters.

    Is my text sent to a server?

    No. Everything runs in your browser and your text is never uploaded or stored.