How To Find And Replace With Regex In Notepad++ (2027)
Quick answer
- Press Ctrl+H, set Search Mode to Regular expression, type your pattern in Find what and the result in Replace with, then click Replace All.
- Refer to a captured group in Replace with as $1, 1 or \1; leave Replace with empty to delete whatever matched.
- Click Find Next first to test a pattern, because the Invalid regular expression error only appears then.
Applies to: Notepad++ for Windows (Boost regular expression engine, current user manual)
Notepad++ can find and replace text with regular expressions, which is the quickest way to reshape a long file.
You switch the feature on in the Replace window by choosing Regular expression as the search mode.
This guide follows the Notepad++ user manual and was checked on November 29, 2026.
Table of Contents
Quick answer: regex find and replace
| Step | What to do |
|---|---|
| Open the window | Press Ctrl+H (Search > Replace). |
| Turn on regex | Set Search Mode to Regular expression. |
| Enter the pattern | Type it in Find what, then click Find Next to test it. |
| Enter the result | Type it in Replace with, or leave it empty to delete matches. |
| Apply it | Click Replace All. |
Run a regex replace
- Press Ctrl+H, or choose Search > Replace.
- Under Search Mode, choose Regular expression.
- Type your pattern in Find what.
- Click Find Next to test it.
- Type the replacement in Replace with.
- Click Replace All.
The manual says Replace with can be empty, which deletes the matched text.
Notepad++ uses the Boost regular expression engine, and Match whole word only becomes unavailable in this mode.
The three search modes
| Mode | What it does |
|---|---|
| Normal | Matches the text literally. |
| Extended | Interprets escapes such as \n, \r, \t, \0 and \x. |
| Regular expression | Uses the Boost regex engine. |
In regex mode, the . matches newline checkbox controls whether a dot matches line endings, and the inline modifiers (?s) and (?-s) do the same.
Match case can be overridden inside a pattern with (?i) and (?-i).
Pattern syntax you will use most
| Token | Meaning |
|---|---|
| ^ and $ | Start and end of a line. |
| \A and \z | Start and end of the file. |
| *, + and ? | Zero or more, one or more, and zero or one. |
| *? and +? | Lazy versions that match as little as possible. |
| (…) | A numbered capture group. |
| (?:…) | A non-capturing group. |
| \R | Any newline sequence; it cannot be used inside a character class. |
| [[:alpha:]] | A named character class. |
Write the replacement
| In Replace with | Result |
|---|---|
| $1, 1 or \1 | The text captured by group 1; use braces above group 9. |
| $0 or $& | The whole match. |
| $$ or \$ | A literal dollar sign. |
| \u or \l | Changes the next character to upper or lower case. |
| \U or \L | Changes case until \E. |
In the search field, backreferences \1 to \9 take a single digit only, so \10 means group 1 followed by 0.
Search and replace syntax differ, so do not copy a search token into the replacement unchanged.
Example: delete lines that contain a word
The manual’s first example deletes every line that contains the word unused.
Put this in Find what and leave Replace with empty, and Replace All removes each matching line.
Example: reorder dates
The manual’s date example turns day.month.year into year-month-day.
This is the Find what pattern, which captures the spaces, day, month and two-digit year as groups 1 to 5.
This is the Replace with text, which puts the groups back in the order year, month, day.
Example: add text to the start of every line
The manual’s file URL example adds a prefix to each non-empty line.
Use it in Find what and put file:/// in Replace with.
Control what Replace All covers
In selection limits Count, Replace All and Mark All to the text you have selected.
Replace All in All Opened Documents applies the replacement in every open file.
The manual says Replace All with regex is equivalent to running the regex repeatedly, not the /g flag found in many programming languages.
Replace All’s scope also depends on the caret position, Wrap around and Backward direction.
Warnings from the manual
- An invalid regex only triggers the Invalid regular expression error when you click Find Next, so test first.
- Regex backward search is disabled by default because results can be surprising.
- The Find what box is limited to 16383 bytes, not characters.
- A pattern like [^ABC]* can match across newlines unless you exclude \r\n from the set.
Save a copy of the file before a large Replace All, or see our guide to recovering unsaved or lost files in Notepad++.
If you do not have the editor yet, start with how to download and install Notepad++ safely.