Notepad++ has a Find feature with which you can search for any text in a file. But it doesn’t end there.

You can also use Notepad++'s Find and Replace feature to search for a text and replace it with a specified replacement.

The Find and Find and Replace features accept regular text, but they both also accept regular expressions.

Let's see how the Find and Find and Replace feature of Notepad++ works by using regular expressions instead of regular text.

How to Find a String with Regular Expressions in Notepad++

This is the code I'll use for this demo:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Find String with RegEx in Notepad++</title>
  </head>
  <body>
    <h1>Find String with RegEx in Notepad++</h1>

    <h2>Lorem ipsum dolor sit.</h2>
    <p>
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eius beatae
      dignissimos alias quo odit aperiam laborum accusamus ea maxime dolores?
    </p>
  <h3>Lorem ipsum dolor sit amet.</h3>

    <h2>Lorem ipsum dolor sit.</h2>
    <p>
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae voluptatem
      perferendis iure laborum inventore ducimus harum saepe voluptatibus neque
      earum?
    </p>
  <h3>Lorem ipsum dolor sit amet.</h3>

    <h2>Lorem ipsum dolor sit.</h2>
    <p>
      Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magnam
      accusantium placeat dolore illo, quidem suscipit. Recusandae corrupti
      assumenda soluta libero!
    </p>
  <h3>Lorem ipsum dolor sit amet.</h3>

    <h2>Lorem ipsum dolor sit.</h2>
    <p>
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Cupiditate
      officia rerum id inventore sunt deleniti quaerat quibusdam libero vero
      non?
    </p>
  <h3>Lorem ipsum dolor sit amet.</h3>
  </body>
</html>

Once you've opened your file in Notepad++, press CTRL + H to open the Find popup. Make sure you're in the Find tab because the Replace tab is what opens by default.

After that, select Regular expression:

ss1-3

Next, enter your regular expression in the search input. I want to search for all Heading elements, so I'll enter the regex <h(1|2|3|4|5|6)>

After entering the regex, click the Find Next button. It may also appear as "Find":

ss2-1

To keep seeing the matches, you have to keep clicking the "Find Next" button. However, you can click the "Count" button to see all your matches:

ss3-1

How to Find and Replace a String with Regular Expressions in Notepad++

You can perform find and replace almost the same way. The only difference is that you select the "Replace" tab instead of "Find":

ss4-1

The search regex gets automatically populated, so what you need to do here is specify what to replace the matches with and the click Replace.

Let's say I want to replace all headings with a p tag:

ss5-2

Instead of clicking "Replace" repeatedly to replace the matches, you can click the "Replace All" button:

ss6-1

I'm also going to find all the closing heading tags with this regex <\/h(1|2|3|4|5|6)> and replace them with closing p tags.

Now, this is what the code looks like:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Find String with RegEx in Notepad++</title>
  </head>
  <body>
    <p>Find String with RegEx in Notepad++</p>

    <p>Lorem ipsum dolor sit.</p>
    <p>
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eius beatae
      dignissimos alias quo odit aperiam laborum accusamus ea maxime dolores?
    </p>
	<p>Lorem ipsum dolor sit amet.</p>

    <p>Lorem ipsum dolor sit.</p>
    <p>
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae voluptatem
      perferendis iure laborum inventore ducimus harum saepe voluptatibus neque
      earum?
    </p>
	<p>Lorem ipsum dolor sit amet.</p>

    <p>Lorem ipsum dolor sit.</p>
    <p>
      Lorem ipsum dolor, sit amet consectetur adipisicing elit. Magnam
      accusantium placeat dolore illo, quidem suscipit. Recusandae corrupti
      assumenda soluta libero!
    </p>
	<p>Lorem ipsum dolor sit amet.</p>

    <p>Lorem ipsum dolor sit.</p>
    <p>
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Cupiditate
      officia rerum id inventore sunt deleniti quaerat quibusdam libero vero
      non?
    </p>
	<p>Lorem ipsum dolor sit amet.</p>
  </body>
</html>

Conclusion

Find and Replace is a great feature that saves you a ton of time in Notepad++, especially if you have to replace text in a large file.

Since VS Code is the most popular code editor these days, it also has its own find and replaces feature you can access by pressing CTRL + H. And if you want to search with regex, you can press the .* button:

ss7-1

Thank you for reading.