KOMPX.COM or COMPMISCELLANEA.COM   

Match any character in Notepad++ replace

Matching any character while searching and replacing in Notepad++ editor:


[\s\S]*?

Example

Removing unnecessary P tags in the following HTML code:


<div class="example">
	<ul>
		<li><p>Text</p></li>
		<li>
			<p>Text</p>
		</li>
	</ul>
</div>

  1. Ctrl + H
  2. Find What: <li>[\s\S]*?<p>(.*)</p>[\s\S]*?</li>
  3. Replace With: <li>\1</li>
  4. Wrap around
  5. Search Mode: Regular expression
  6. Replace All

"Replace" dialogue in Notepad++

After running Replace with that regex, the code is going to end up like this:


<div class="example">
	<ul>
		<li>Text</li>
		<li>Text</li>
	</ul>
</div>

Links

  1. Regex to match any character including new lines [duplicate] stackoverflow.com/questions/8303488/regex-to-match-any-character-including-new-lines
  2. matching any character including newlines in a Python regex subexpression, not globally stackoverflow.com/questions/33312175/matching-any-character-including-newlines-in-a-python-regex-subexpression-not-g
  3. How do I match any character across multiple lines in a regular expression? stackoverflow.com/questions/159118/how-do-i-match-any-character-across-multiple-lines-in-a-regular-expression
Operating systems
More