Notepad++ regular expression syntax

http://blog.csdn.net/pipisorry/article/details/21781111
notepad++ regular expression usage (continuously updated), delete, replace, find operations
Regular expression reference [regular expression Linux\Python\django\notepad++]
CTRL+H Select regular expression
Pippi Blog

delete operation
notepad++ Remove trailing spaces or commas
Search target: \s+$ (or ,+$)
is replaced with empty
Note: Ending with a newline character means $\r\n, not \r\n$
notepad++ delete blank lines in the text file
search target: ^[ \t]*\n or: ^\r\n
replace with empty
notepad++ delete the line with only numbers
search target: ^[\d]+$ Replace \r\n
with empty
notepad++ to remove lines that do not start with a certain number
Search target: ^[^1].*\r\n
Replace with empty
notepad++ to remove <> in all lines (<> cannot be nested inside)
Find target: <[^>]*>
replace with empty
input:
<code><span class="kwd">import</span><span class="pln"> </span><dfn><span class="typ">BaseHTTPServer</span></dfn><span class="pln">
</span><span class="kwd">import</span><span class="pln"> </span><dfn><span class="typ">SimpleHTTPServer</span></dfn><span class="pln">
</span><span class="kwd">import</span><span class="pln"> </span><dfn><span class="typ">CGIHttpServer</span></dfn></code>
output: and then blank line is removed \1\r\n is replaced by ^(.*?)#.*?\r\n search target (re) is replaced by empty, #comment removed ^.*?'''\r\n.*?\r\n.* ?'''\r\n Find the target (regular expression) notepad++ Remove the comments in the python code Remove import CGIHttpServer import SimpleHTTPServer
import BaseHTTPServer













If you only remove the commented line without removing the #comment followed by the code, the search target is
^\s+#.*?\r\
nPipi Blog


replacement operation
notepad++ replaces (Week 1) \n II. in all lines for;
Find target: \([^\.]*\.
Replace with empty
input:
I. Introduction Machine Learning Review (Week 1)

II. Linear Regression with One Variable Univariate Linear Regression (Week 1)

III. Linear Algebra Review Linear Algebra (Week 1, Optional)
output:
I. Introduction Machine Learning Overview; Linear Regression with One Variable Univariate Linear Regression; Linear Algebra Review Linear
Algebra Begin; [^\.]* Represents non-character. The character repeats n times; \. Represents until the character.
Notepad++ replaces [] and the included letters with empty
Search target
[/]*[[:alpha:]]*
Replace with empty
input:
[cp] — Do you see me as a singer? — No. [/cp] [cp] Why can’t I grow taller? Maybe you have acrophobia[/cp] [cp]
output:
- Do you think I'm a singer? -no. Why can't I grow taller anymore? Maybe you have acrophobia 
notepad++ to replace the matching content in parentheses\1
1. When localizing, do you often encounter such sentences that need to be translated:
"Error adding the post!";
"Error adding the comment!"; "Error adding the comment!"
; adding the user!";
Find target:
"Error adding ([^!|"|;]*) is
replaced by:
"An error occurred while adding \1
The result is:
"An error occurred while adding the post!";
"In An error occurred while adding the comment!";
"An error occurred while adding the user!";
Note:
1. ([^!|"|;]*) means not equal to any of ! and " and ;, It means that all characters other than these 3 characters will be selected (replacement area);
2. In the regular expression, \1 represents the matching content in the first bracket.
The regular expression will replace the last \t with =>
biscuits milk
yoghurt milk
tomato souce pasta
tomato souce milk
water pasta milkFind
target: (RE)
\t(\w+?)\r\n
is replaced by:
=>\1\r\ nResult
:
biscuits=>milk
yoghurt=>milk
tomato souce=>pasta
tomato souce=>milk
water pasta=>milk
regular expression Replace the beginning of the number with a number. The beginning
1.os.sep can replace
2.os.name
3os
Find the target:
^(\d+)\.*
Replace with:
\1.
Result:
1.os.sep can replace
2.os In .name
3.os
Notepad++ add * between decimals and letters
Search target
(\d\.\d+)
is replaced by
\1\*
input:
0.95c == 0.9b + 0.475a
c == 0.9b + 0.475 a
0.85a == c + 0.15b
c == b + 0.575a
output:
0.95*c == 0.9*b + 0.475*a
c == 0.9*b + 0.475*a
0.85*a == c + 0.15*b
c == b + 0.575*a
Add quotes to strings in Notepad++
Find target
(\w+) and
replace it with
'\1'
input :
c, i, nd, o, p, u
output:
'c', 'i', 'nd', 'o', 'p', 'u'
Notepad++ Change each line of assignment statement to a judgment statement
Find target
^ (.*)$
is replaced with
if \1 :\n\tprint'True'
input:
0.95*c == 0.9*b + 0.475*a
c == 0.9*b + 0.475*a
0.85*a == c + 0.15 *b
c == b + 0.575*a
output:
if 0.95*c == 0.9*b + 0.475*a :
    print('True')
if c == 0.9*b + 0.475*a :
    print('True')
if 0. 85*a == c + 0.15*b :
    print('True')
if c == b + 0.575*a :
    print('True')
Pipi Blog


search operation
notepad++Find the matching content in parentheses\
1Find out (0 0 1)(0 1 1)T, The content in the parentheses in x③=(-1 0 -1)T, x④=(-1 -1 -1)
Find target:
.*?((-*\d\s*)+).*?
Replace with:
\1
The result is:
(0 0 1)(0 1 1)(-1 0 -1)(-1 -1 -1)
Note: This search effect is not very good, it is not enough to write re.findall() in python Effect.
notepad++ finds the content in brackets ()\ 1Find
out
        ω1: {(1 0)T, (2 0) T, (1 1) T}
        ω2: {(-1 0)T, (0 1) T, ( -1 1) T} ω3: The content in the parentheses in
        {(-1 -1)T, (0 -1) T, (0 -2) T} Find the target: .*?(\-*\d\s \-*\d).*? is replaced by: \1 The result is: (1 0)(2 0)(1 1) T}







(-1 0)(0 1)(-1 1) T}
(-1 -1)(0 -1)(0 -2) T}
I also need to delete the extra T} behind it, I don't know what else A better way to find?
from:http://blog.csdn.net/pipisorry/article/details/21781111Reference

:http://blog.csdn.net/pipisorry/article/details/21781111

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326440247&siteId=291194637