NotePad ++ regular expression turn

https://gerardnico.com/ide/notepad/replace
https://notepad-plus-plus.org/community/topic/16787/find-and-replace-using-regular-expression

http://www.pnotepad.org/docs/search/regular_expressions/


TotalErrSaAddr=(.,)    //5955 (包含0 和1~9)
TotalErrSaAddr=(..,)   //63
TotalErrSaAddr=(...,)   //2
TotalErrSaAddr=(....,)  //0

TotalErrSaAddr=(*,)  //error

TotalErrSaAddr=(.,)    //5955


==============
TotalErrSaAddr=([0],)     //4714
TotalErrSaAddr=([1-9],)  //1241
    TotalErrSaAddr=([1-8],) //1230
    TotalErrSaAddr=([9],)  //11



TotalErrSaAddr=([1-9][0-9],)  // 63
TotalErrSaAddr=([1-9][0-9][0-9],)  //2









^case "TotalErrSaAddr=/(\w+)\.php"

^case “TotalErrSaAddr=/[a-Z0-9]*"


TotalErrSaAddr=>0



([^-]*).*

([^TotalErrSaAddr=]*).*



TotalErrSaAddr=([^-]*).*     //ok   3010

TotalErrSaAddr=([a-Z0-9]*)




TotalErrSaAddr=([1-9],)  //ok  1241
TotalErrSaAddr=([9-999],) //ok, 11个,   9~999个错误saAddrNum


TotalErrSaAddr=([0-9],)   //ok 5955  ,0~9的数据,后面跟,


TotalErrSaAddr=([^-]*)     //ok  6020

TotalErrSaAddr=   //ok 6020





TotalErrSaAddr=


BINON:00000000,00000000,00000000,0000([1-3])([1-3])([1-3])([1-3]);

//找  ??3的值,   ?可以是空到任意   
BINON:00000000,00000000,00000000,0000(.[3])

https://blog.csdn.net/wangkai_123456/article/details/55254598

When we deal with files, often you will use Find and Replace. When we want to file a partial replacement of another part of the document replaced, how to do it? The following regular expression to provide me method.

Regular expressions provide sophisticated and flexible search and replace

Note: does not support multi-line expressions (involving \ n, \ r, etc).

To choose the
regular expression search

1 Basic Expressions

symbol Explanation
. Matches any character except a new line (\ n). That is to say. "" Match \ r, when the document contains the same time \ r and \ n, the confusing. To match all the characters, use \ s \ S
(…) This matches a tag area. This tag can be accessed by the syntax \ 1 accesses the first tag, \ 2 to access the second, similarly \ 3 \ 4 ... \ 9. These labels may be used in this regular expression, or for the search and replace the string change.
\1, \2, etc Representative label area 1-9 in the alternative (\ 1 to \ 9). For example, the search string Fred ([1-9]) XXX and replace string methods Sam \ 1YYY when Fred2XXX string found in the file is replaced Sam2YYY. Note: Only nine regions can be used, so we're safe when used, like \ 10 \ 2 represents a region 1 and the text "0" and the area 2.
[…] It represents a set of characters, such as [abc] represents any character a, b or c. We can also use the range, for example [az] Therefore, the lower case letters represent.
[^…] It represents a character complement. For example, [^ A-Za-z] represents any character except alphabet.
^ Start matching line (except in the collection, below).
$ Matching the line.
* Match 0 or more times, e.g. Sa * m matches Sm, Sam, Saam, Saaam like.
+ Matching one or more times, e.g. Sa + m matches Sam, Saam, Saaam like.
? Match 0 or 1, e.g. Sa? M matches Sm, Sam.
{n} Matching the determined n times. For example, 'Sa {2} m' matches Saam.
{m,n} Matching at least m times, up to n times (n if missing, then any number of times). For example, 'Sa {2,3} m' matches Saam or Saaam. 'Sa {2,} m' and 'Saa + m' same
*?, +?, ??, {n,m}? Non-greedy matching, matching the first valid match, usually '<>' will match the whole 'content' string - but '<?>' Matches only, "This marks a label areas, which you can use the syntax \ 1 \ 2, etc. corresponding to the plurality of access regions 1-9.

2 and a packet marking

symbol Explanation
(…) A set of capture may be by \ 1 accesses the first group, \ 2 to access the second.
(?:…) Non-capturing group.
(?=…) Non-capturing group - forward assertions such as '(= ton?) (*.)' Expression, when it comes to 'Appleton' string, it will match the 'Apple'..
(?<=…) Non-capturing group - rearward assertions e.g. '(<= sir?) (*.)' Represented by formula, when faced 'sir William' string match the 'William'..
(?!…) Non-capturing group - such as the expression of negative assertion forward, when faced with 'Apple', in addition to find each letter 'l', because it is followed by 'e'. '(?! e).'.
(? Non-capturing group - such as back negative assertions' (.?
(?P…) Named captured group. Submit a name to the group for subsequent use, for example, '(? PA [^ \ s] +) \ s (? P = first)' find 'Apple Apple'. Similar '(A [ ^ \ s] +) \ s \ 1 'with a group name rather than a number.
(?=name) Matching group named name. (? P ...).
(?#comment) Annotations - in brackets in the match will be ignored.

3 special symbols

symbol Explanation
\s Matching note the space, marking the end of the match will use [[: blank:]]. To avoid matching the new line.
\S Matching non-blank
\w Matching word character
\W Matches non-word character
\d Matching numeric characters
\D Matching non-numeric characters
\b Matching word boundaries. '\ BW \ w +' to find words that begin with W
\B Non-word boundary matching '\ Be \ B +' -. In the middle of the list to find the letter 'e'
< This matches the start of a word using Scintilla’s definitions of words.
> This matches the end of a word using Scintilla’s definition of words.
\x Run by x to express the characters may have other meanings. For example, [for insertion into the text as [not set as the start character.

4 character classes

symbol Explanation
[[:alpha:]] Match alphabetic characters: [A-Za-z]
[[:digit:]] Matching numeric characters: [0-9]
[[:xdigit:]] Match hexadecimal characters: [0-9A-Fa-f]
[[Charon]] Match alphanumeric characters: [0-9A-Za-z]
[[:lower:]] Matching lowercase characters: [az]
[[:upper:]] Matching uppercase characters: [AZ]
[[:blank:]] Matching blank (space or tab): [\ t]
[[:space:]] Match whitespace: [\ t \ r \ n \ v \ f]
[[:point:]] Match punctuation characters:! [- "# $% & '() * +, / :; <=> @ [] _` {.?
[[:graph:]] Matching graphic characters: [\ x21- \ x7E]
[[:print:]] 匹配可打印的字符 (graphical characters and spaces)
[[:cntrl:]] 匹配控制字符

5 替换操作

使用正则表达式的标记,通过()来包围想要用的字符,然后用\1 来替换字符串,第一个匹配文本。

例如:
Text body   Search string   Replace string  Result
Hi my name is Fred  my name is (.+)     my name is not \1   Hi my name is not Fred
The quick brown fox jumped over the fat lazy dog    brown (.+) jumped over the (.+)     brown \2 jumped over the \1     The quick brown fat jumped over the fox lazy dog

6 限制

Support for regular expressions in PN2 is currently limited, the supported patterns and syntax are a very small subset of the powerful expressions supported by perl. 最大的限制是正则表达式只能匹配单行,不能用多行匹配表达。可以用Backslash Expressions代替.

准备计划是使用PCRE库 library (used elsewhere in PN2) 来支持文档搜索.

7应用举例

删除空白行的方法
方法:
选择替换,把查找模式设置为正则表达式,在查找框中输入 ^\s+  ,替换框留空,点“全部替换”,即可(先全选)。
删除所有行s字符开始后面的所有字符

方法:
选择替换,把查找模式设置为正则表达式,在查找框中输入 ^([^:]*):.*$,替换框填写$1,点“全部替换”,即可(先全选)。

Guess you like

Origin www.cnblogs.com/scotth/p/11511163.html