Complete explanation of Notepad++ regular commands - Xiaohei's super detailed explanation

   Notepad is a text editor tool. It is a free open source tool for Windows. It has many functions and can also run scripts. I haven’t studied it in detail, but it is very convenient to use. Let’s record what you use in daily use.

Download: Notepad++ · GitHub

Table of contents

 Give a chestnut:

 Simple use of regular

Regular symbol interpretation

Tagging and grouping


 

 Give a chestnut:

         Take a scenario like this: You have a bunch of URLs, but you need to wrap them in new lines. Then we can use the symbols (or even spaces) between each URL to simply use regular matching to complete the new lines.

 

Use ctrl + F to match "," and replace it with the newline character "\r\n"

 

 Simple use of regular

A simple use of regular expressions when expanding, you can use expressions that escape characters

character meaning
  ”." It means matching all characters similar to this pair.
“\s" Matches all whitespace characters (including tabs)
”\d" match all numbers
"\S" match all strings
"\D" Match all non-digits
“ * ” Represents greedy matching, which will continue to match the last one that meets the conditions.
" ? " Only one match
“ + ”  matches one or more

“ \t "

Matches a tab character
” \r “ Match newline
” \n " Match newline

Regular symbol interpretation

           Reasonable use of regular expressions can efficiently process text.

basic expression
symbol explain
【.】 Match any character, except new line (\n). To match all characters, you need to add \s
(...) Matches a label area. This label can be accessed. The first label is accessed through the syntax \1 (in the same way, other numbers can be accessed by connecting numbers)
\1,\2,etc

Represents the label range 1-9 in replacement (\1 to \9),

Example: How to find the string Fred ([1-9])xxx and replace it with the string sam\1YYY

[...] Represents a set of characters, for example [abc] represents any character a, b or c. We can also use a range such as [az] to represent all lowercase letters
[^...] Represents the complement of characters, for example, [^A-Za-z] represents any character except the alphabet
^

Matches the start of a line (unless in a collection)

Column: ^[*] matches characters starting with *, without parentheses * is a global matching symbol

$ Matches the last line starting with xxxx
*

Match 0 or more times

For example: sa*m will match sam, samm, saaam

+

Match 1 or more times

For example: sa+m matches sam, saam

?

Match 0 or 1 times

For example: sa? m matches sm, sam

{n}

Match determined n times

For example: sa{2}m matches saam

{m,n}

Match at least m times, and at least n times (or any number of times if n is missing)

For example: sa{2,3}m, matches saam or saaam

*?,+?,??,{n,m}? Non-greedy matching, matching the first valid match, usually <.> will match the entire content string

Tagging and grouping

Tag grouping
(...) A group of captures, the first group can be accessed via \1 and the second one via \2
(?...) non-capturing group
(?=...)

forward assertion

Example: (.*)(?=ton), when encountering aston, it will match 'ass'

(?<=...)

Assert backwards

Example: (?<=sir)(.*) When encountering ss sir aa, it will match 'aa'

(?P...)

Submit a name to the group for later use

example: 

Guess you like

Origin blog.csdn.net/G_WEB_Xie/article/details/130574539
Recommended