Notepad++ regex replace wildcard capture group

Notepad++ regex table

Regex Example Group Text
Find what Before Replace With After
\u\w+ Aristotel \l$0\E aristotel
(. –)([A-Z])(.+) . -Aristotel N/A N/A
( -)([A-Z])(.+) -Aristotel ;man;1;0 N/A N/A
( ~)([A-Z])(.+) ~Aristotel ! not N/A N/A
^\u[\w+\s]+\r\n Seoul South Korea N/A N/A
\b\u[\w+\s]+[\r|\s]\b Guangzhou China N/A N/A
[0-9]+. 3. 1. 'Yes!' 2. N/A N/A
((\w)+) ' Animal 'Tiger ['\1', [' ['Animal', ['Tiger
\w+,$ Tiger, Lion, Mouse , '\1' 'Tiger', 'Lion', 'Mouse'
(\d+)(\s)+(\d+) 456 872 \1 separate \3 456 separate 872
(.*)\r\n Java 9 "\1",\r\n "Java 9",
(.*)="(\d+)" class="1505" $2 1505
([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)$ blog.softhints.com N/A N/A
(.*)([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+)$ blog.softhints.com \2.\3 softhints.com
(\b\d+)\s(\u) 1 Hong Kong Hong \1@\2 1@Hong Kong Hong
(\u|\l)\s(\d) Rome Italy 9,396.4 \1@\2 Rome Italy@9,396.4
\n\n(\d) 1. Clean the code

2. Check for errors
\n%\n$1 1. Clean the code
%
2. Check for errors
\d+\. 1. Clean the code * * Clean the code

How to use the table:

  • Open Notepad++
  • Replace menu
  • Set Search mode to Regular Expression
  • Fill Column REGEX / FIND WHAT
  • Fill Column GROUP / REPLACE WITH - in case of N/A this would remove the found result; for example: 1000$$ -> 1000 if you want to remove $$
  • Test result by find
  • Do back up of the file
  • Replace All and compare results

Notepad++ regex replace numbers

  • Open Notepad++ with the file for replace
  • Replace menu Ctrl+H
  • or Find menu - Ctrl+F
  • check the Regular expression (at the bottom)
  • Write in Find what
  • \d+
  • Replace with:
  • X
  • ReplaceAll

Before:

text
23	45
456	872

After:

text
X	X
X	X

Notepad++ regex replace capture groups

  • Open Notepad++ with the file for replace
  • Replace menu Ctrl+H
  • or Find menu - Ctrl+F
  • check the Regular expression (at the bottom)
  • Write in Find what
  • (\d+)(\s)+(\d+)
  • Replace with:
  • \1 separate \3
  • ReplaceAll

Before:

234	45
46	872
1569	489
718	357
789 941

After:

234 separate  45
46 separate  872
1569 separate  489
718 separate  357
789 separate  941

Notepad++ regex add quotes and commas

  • Open Notepad++ with the file for replace
  • Replace menu Ctrl+H
  • or Find menu - Ctrl+F
  • check the Regular expression (at the bottom)
  • Write in Find what
  • (.*)\r\n
  • Replace with:
  • "\1",\r\n
  • ReplaceAll

Before:

Java
Java 9
Python 
Javascript

After:

"Java",
"Java 9",
"Python ",
"Javascript",

Notepad++ regex add character on empty lines

In this example you can see how to quickly prepare texts for Linux program Fortunes. You can this simple regular expression in order to update whole document (with hundreds of lines) and save your time. The examples are shown below:

Before:

1. Clean the code

2. Check for errors

3. Add comments

...

After:

1. Clean the code
%
2. Check for errors
%
3. Add comments
%
...
  • Open Notepad++ with the file for replace
  • Replace menu Ctrl+H
  • or Find menu - Ctrl+F
  • check the Regular expression (at the bottom)
  • Write in Find what
  • \n\n(\d)
  • Replace with:
  • \n%\n$1
  • ReplaceAll

Notepad++ regular expression to replace numbering with bullet points

Often in work we need to deal with numbering and bullet points. Most of the programs can handle this automatically. Yet sometimes you will need to do this manually or by hand. In this example you can find regex which can do this for you:

  • find - \d+\.
  • replace - *

Before:

1. Clean the code

2. Check for errors

3. Add comments

...

After:

* Clean the code

* Check for errors

* Add comments

...