正则表达式中的运算符优先级 [英] Operator precedence in regular expressions
问题描述
当 Oracle 的正则表达式不包含括号时,它们的默认运算符优先级是多少?
What is the default operator precedence in Oracle's regular expressions when they don't contain parentheses?
例如,给定
H|ha+
它会被评估为 H|h
然后像 ((H|h)a)
那样连接到 a
,还是会H
与 ha
交替,如 (H|(ha))
?
would it be evaluated as H|h
and then concatenated to a
as in ((H|h)a)
, or would the H
be alternated with ha
as in (H|(ha))
?
另外,+
什么时候开始,等等?
Also, when does the +
kick in, etc.?
推荐答案
鉴于 Oracle 文档:
表 4-2 列出了支持在传递给 SQL 正则表达式函数和条件的正则表达式中使用的元字符列表.这些元字符符合 POSIX 标准;行为与标准的任何差异都在描述"列中注明.
Table 4-2 lists the list of metacharacters supported for use in regular expressions passed to SQL regular expression functions and conditions. These metacharacters conform to the POSIX standard; any differences in behavior from the standard are noted in the "Description" column.
然后查看该表中的 |
值:
And taking a look at the |
value in that table:
表达式 a|b 匹配字符 a 或字符 b.
The expression a|b matches character a or character b.
另外看看POSIX 文档:
运算符优先级of 运算符的优先顺序如下:
Operator precedence The order of precedence for of operators is as follows:
与排序规则相关的括号符号 [==] [::] [..]
Collation-related bracket symbols [==] [::] [..]
转义字符 \
字符集(括号表达式)[]
Character set (bracket expression) []
分组()
单字符 ERE 重复 * + ?{m,n}
Single-character-ERE duplication * + ? {m,n}
串联
锚定 ^$
交替|
我会说 H|ha+
与 (?:H|ha+)
相同.
I would say that H|ha+
would be the same as (?:H|ha+)
.
这篇关于正则表达式中的运算符优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!