正则表达式列表

字符

结果/使用

任何字符

如果没有其他指定则代表给定的字符。

.

代表除换行符和分段符之外的任意单个字符。例如,查找 "sh.rt" 将同时返回 "shirt" 和 "short"。

^

仅查找位于段首的查找项。段首的特殊对象(例如,空白间隔和与字符锁定在一起的框架)将被忽略。例如 '^Peter'。

$

仅查找位于段尾的查找项。段尾的空白区间或与字符锁定的框架等特殊对象将被忽略,例如 "Peter$"。

单独的 $ 可匹配段落末尾。这样就可以搜索替换分段点了。

*

查找 '*' 前的一个字符出现N(N≥0)次的情况。例如,'Ab*c' 将查找 'Ac'、'Abc'、'Abbc'、'Abbbc' 等。

+

查找 "+" 前的一个字符出现N(N≥1)次的情况。例如输入 'AX.+4' 将找到 'AXx4',而不是 'AX4'。

始终查找段落中匹配此查找模式的最长的可能字符串。如果段落包含字符串 "AX 4 AX4",则突出显示整个段落。

?

查找 "?" 前的一个字符出现N(N=0 或 N=1)次的情况。例如,"Texts?" 将查找 "Text" 和 "Texts",而 "(ab|c)?y" 将查找 "xy"、"xaby" 或 "xcy"。

\

查找将在 "\" 之后的特殊字符视为普通字符而非正则表达式(组合 \n、\t、\> 和 \< 除外)。例如,"tree\." 查找 "tree.",而非 "treed" 或 "trees"。

\n

Represents a line break that was inserted with the Shift+Enter key combination. To change a line break into a paragraph break, enter \n in the Find and Replace boxes, and then perform a search and replace.

\n in the Find text box stands for a line break that was inserted with the Shift+Enter key combination.

\n in the Replace text box stands for a paragraph break that can be entered with the Enter or Return key.

\t

Represents a tab. You can also use this expression in the Replace box.

\b

匹配单词边界。例如“\bbook”可匹配“bookmark”,但不会匹配“checkbook”,而“book\b”可匹配“checkbook”,但不会匹配“bookmark”。前述两例表达式均可匹配单个单词“book”。

^$

查找空段落。

^.

查找段落的首字符。

& 或 $0

在替换时,将根据查找框中输入的条件找到的字符串,添加到替换框的内容中。

例如,如果在查找框中输入 "window",在替换框中输入 "&frame",则将使用 "windowframe" 替换 "window"。

您也可以在替换框中输入 "&",修改按查找条件查找的字符串的属性格式

[abc123]

代表括号中的某个字符。

[a-e]

Represents any of the characters that are between a and e, including both start and end characters.

该字符按照代码编号排序。

[a-eh-x]

Represents any of the characters that are between a-e and h-x.

[^a-s]

Represents everything that is not between a and s.

\uXXXX

\UXXXXXXXX

代表了以4位十六进制Unicode代码 (XXXX) 表示的字符。

对于生僻字符,另有一个以大写U开头的8位十六进制代码表示方法 (XXXXXXXX)。

对于特定的符号字体(symbol fonts),特殊字符的代码可能会依赖于所使用的字体。您可以在插入 - 特殊字符中预览其代码。

|

查找 "|" 两边出现的内容。例如,对于 "this|that" 将找到 "this" 和 "that"。

{2}

定义左括号前面的字符的出现次数。例如,"tre{2}" 将找到并选中 "tree"。

{1,2}

定义左括号前面的字符出现的最小和最大次数。例如,"tre{1,2}" 将找到并选中 "tre"和 "tree"。

{1,}

定义左括号前面的字符出现的最小次数。例如,"tre{2,}" 可以找到 "tree"、"treee" 以及 "treeeee"。

( )

In the Find box:

将括号中的字符定义为一个引用。然后可在当前表达式中,使用 '\1' 指向第一个引用,使用 '\2' 指向第二个引用,以此类推。

For example, if your text contains the number 13487889 and you search using the regular expression (8)7\1\1, "8788" is found.

You can also use () to group terms, for example, "a(bc)?d" finds "ad" or "abcd".

In the Replace box:

Use $ (dollar) instead of \ (backslash) to replace references. Use $0 to replace the whole found string.

[:alpha:]

Represents an alphabetic character. Use [:alpha:]+ to find one of them.

[:digit:]

Represents a decimal digit. Use [:digit:]+ to find one of them.

[:alnum:]

代表一个字母数字字符(字母和数字)。

[:space:]

代表空格字符(但不代表其他空白字符)。

[:print:]

代表一个可打印字符。

[:cntrl:]

代表一个非打印字符。

[:lower:]

如果在选项中选择区分大小写,则显示小写字符。

[:upper:]

Represents an uppercase character if Match case is selected in Options.


For a full list of supported metacharacters and syntax, see ICU Regular Expressions documentation

示例

e([:digit:])? -- finds 'e' followed by zero or one digit. Note that currently all named character classes like [:digit:] must be enclosed in parentheses.

^([:digit:])$ -- finds lines or cells with exactly one digit.

您可以组合搜索条目来构成复杂搜索。

在段落中查找单独的三位数。

^[:digit:]{3}$

^ 表示匹配必须在段落起始处,

[:digit:] 与任何十进制数字匹配,

{3} 表示必须精确地有三个“数字”副本,

$ 表示匹配必须结束段落。