Expression Description
\t Tab字符
\n 新行
. 匹配任意字符
| 匹配"左边和右边"的字符串, 例如: "ac|ad" 匹配 "ac" 和 "ad"
[] 匹配所有在 符号"[]"闭合区间内 的任意字符, 例如: "[ab]" matches "a" and "b". "[0-9]" matches any digit.
[^] 匹配所有不在 符号"[]"闭合区间内 的任意字符, 例如: "[^ab]" 匹配所有除了"a"和"b"之外的字符, "[^0-9]" 匹配所有非数字字符
* 匹配符号"*"的左边字符(0次或多次) 例如:"be*" 匹配 "b", "be" , "bee"
+ 匹配符号"+"的左边字符(1次或多次) 例如:"be+" 匹配 "be" and "bee", 但不匹配 "b"
? 匹配符号"?"的左边字符(0次或1次) 例如:be?" 匹配 "b" 和 "be", 但不匹配 "bee"
^ 匹配符号"^"的右边字符串, 并且该字符串必须在行首, 例如: ^AB 匹配字符串"AB",并且该"AB"必须在行首
$ 匹配符号"$"的左边字符串, 并且该字符串必须在行尾, 例如: AB$ 匹配字符串"AB",并且该"AB"必须在行尾
() Affects evaluation order of expression and also used for tagged expression.
\ Escape character. If you want to use character "\" itself, you should use "\\".
技巧:
1. 查找空行 : "^[ \t]*\n"
2. 查找行首序号: "^[0-9. ]+"
例如:
"
1. aaaa
2. bbbb
:
100. abcd
:
"
3. 查找"["和"]"之间的内容: "\[.+\]"
4. 匹配<b></b>之间的内容(包括<b></b>):"^\<b\>.+\</b\>"
5. 匹配<b>...<br/>之间没有"/"字符的内容:"^\<b\>[^/]+\<br/\>"
例如:
...
<b>appeal</b> - v. to take to <br/>
<b>somebody for help <br/>
<b>appoint</b> - v. to name;<br/>
<b>statues <br/>
...
使用:^(\<b\>)([^/]+\<br/\>) 和替换串"\2", 将使得以上的第2行和第4行变成:
...
<b>appeal</b> - v. to take to <br/>
somebody for help <br/>
<b>appoint</b> - v. to name;<br/>
statues <br/>
...
The tagged expression is enclosed by (). Tagged expressions can be referenced by \0, \1, \2, \3, etc. \0 indicates a tagged expression representing the entire substring that was matched. \1 indicates the first tagged expression, \2 is the second, etc. See following examples.
Original Search Replace Result
abc (ab)(c) \0-\1-\2 abc-ab-c
abc a(b)(c) \0-\1-\2 abc-b-c
abc (a)b(c) \0-\1-\2 abc-a-c