5.5 级联表达式

Regular expressions may be concatenated; the resulting regular expression matches any string formed by concatenating the substrings that match the concatenated subexpressions.

正则表达式可以是级联 concatenation 的,是不是在讲一个正则表达式里面嵌套一个正则表达式?

两个正则表达式可以通过中缀符号 | 联合,用两个子表达式的任意一个去匹配字符串,例如 abba | cde 要么匹配字符串 abba 要么匹配字符串 cde,要注意在字符集内,即 abba|cde,二选一的匹配不凑效,因为中缀符 | 有它的字面意思。

重复匹配 Repetition 的优先级高于级联,级联高于 | 。 整个子表达式可以括号括起来覆盖这些优先级规则。