What is the default operator precedence in Oracle's regular expressions when they don't contain parentheses?
For example, given
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.?
(i) The regular expression operators have the following order of precedence (in decreasing order): star, concatenation, union.
A regular expression describes a language using three operations. A regular expression (RE) describes a language. It uses the three regular operations. These are called union/or, concatenation and star.
Regular expressions are useful in any scenario that benefits from full or partial pattern matches on strings. These are some common use cases: verify the structure of strings. extract substrings form structured strings.
Given the Oracle doc:
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:
The expression a|b matches character a or character b.
Plus taking a look at the POSIX doc:
Operator precedence The order of precedence for of operators is as follows:
Collation-related bracket symbols [==] [::] [..]
Escaped characters \
Character set (bracket expression) []
Grouping ()
Single-character-ERE duplication * + ? {m,n}
Concatenation
Anchoring ^$
Alternation |
I would say that H|ha+
would be the same as (?:H|ha+)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With