Expression Description
\t Tab字符
\n 新行
. 匹配任意字符
| 匹配"左邊和右邊"的字符串, 例如: "ac|ad" 匹配 "ac" 和 "ad"
[] 匹配所有在 符號"[]"閉合區(qū)間內(nèi) 的任意字符, 例如: "[ab]" matches "a" and "b". "[0-9]" matches any digit.
[^] 匹配所有不在 符號"[]"閉合區(qū)間內(nèi) 的任意字符, 例如: "[^ab]" 匹配所有除了"a"和"b"之外的字符, "[^0-9]" 匹配所有非數(shù)字字符
* 匹配符號"*"的左邊字符(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. 查找"["和"]"之間的內(nèi)容: "\[.+\]"
4. 匹配<b></b>之間的內(nèi)容(包括<b></b>):"^\<b\>.+\</b\>"
5. 匹配<b>...<br/>之間沒有"/"字符的內(nèi)容:"^\<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