notepad++ Regular Expression syntax

Source: Internet
Author: User
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


Replace with:


Method--Find string: abc.*$ replacement string: Hello

Example 2


Replace with:

@abc @
@abcd @

Method--Find string: (abc.*) $ replacement string: @\1@

Example 3


Replace into


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: