notepad++ Regular Expression Syntax
\ escape Character Furu: to use "\" itself, you should use the "\"
\ t Tab TAB Note: Both the extension and the regular expression support
\ r Carriage return CR Note: Extended support, regular expression does not support
\ n newline character LF Note: Extended support, regular expressions do not support
. Match any character
^ The expression to its right is matched at the top of the row. For example: ^a matches a line beginning with "A"
The expression to the left of the line is matched at the end of the row. For example: e$ matches lines ending with "e"
| Or an operator that matches the string to the left and right of the expression. such as: AB|BC matching "ab" or "BC"
[] matches any single character in the list. For example: [AB] matches "a" or "B"; [0-9] matches any single number
[^] matches any single character except the list. For example: [^ab] matches a single character other than "a" and "B"; [^0-9] matches any single non-numeric character
* The character on its left side is matched to any number of times (0 or more times). such as: be* match "B", "Be" or "bee"
+ the character on its left side is matched at least once (1 or more times). such as: be+ match "be" or "bee", but do not match "B"
? The character on the left side is matched 0 or 1 times. such as: be? matches "B" or "be", but does not match "bee"
() The order that affects the expression matching (such as C + + parentheses affects the order of expression operations), and is used as the grouping marker for the expression (marker starting from 1) Note: See the example below
\d matches a numeric character. Equivalent to: [0-9]
\d \d The reverse, matching a non-numeric character. Equivalent to: [^0-9]
\s matches any single whitespace character: including spaces, tabs, and so on (note: Do not include change and line breaks). Equivalent to: [\ t]
\s \s Any single character that is reversed.
\w matches any single character that includes an underscore. Equivalent to: [a-za-z0-9_]
\w \w Any single character that is reversed. Equivalent to: [^a-za-z0-9_]
Example 1
123abcfg
Abc
Abcd
Replace with:
123hello
Hello
Hello
Method--Find string: abc.*$ replacement string: Hello
Example 2
123abcfg
Abc
Abcd
Replace with:
123@abcfg@
@abc @
@abcd @
Method--Find string: (abc.*) $ replacement string: @\1@
Example 3
STR[1]ABC[991]
STR[2]ABC[992]
STR[11]ABC[993]
STR[222]ABC[996]
Replace into
GOD[991]
GOD[992]
GOD[993]
GOD[996]
Method 1--Find string: str\[[0-9]+\]abc\[([0-9]+) \] Replace string: god[\1]
Method 2--Find string: str\[([0-9]+) \]abc\[([0-9]+) \] Replace string: god[\2]
Example 4 Delete all blank lines
Step1:a. Select Regular Expression B. Find string: ^[\t]*$ Replacement string: Empty
Step2:a. Select Extension (\n,\r,\t,\0,\x ...) B. Find string: \r\n\r\n Replacement string: \ r \ n Note: Multiple Click Replace until no replaceable string