Name
{ } (Curly Braces) — Matches a specific number of times
Synopsis
Use curly braces ({}
) when you want to be very
specific about the number of occurrences an operator or subexpression
must match in the source string. Curly braces and their contents are
known as interval expressions. You can specify
an exact number or a range, using any of the forms shown in Table 1-6.
Form |
Meaning |
|
The preceding element or subexpression must occur exactly
|
|
The preceding element or subexpression must occur between
|
|
The preceding element or subexpression must occur at least
|
The following example, taken from Section 1.6, uses curly braces to specify the number of digits in the different phone number groupings:
SELECT park_name FROM park WHERE REGEXP_LIKE(description, '[[:digit:]]{3}-[[:digit:]]{4}');
Using the {m
,n
}
form, you can specify a range of occurrences you are willing to
accept. The following query uses {3,5}
to match
from three to five digits:
SELECT REGEXP_SUBSTR(
'1234567890','[[:digit:]]{3,5}')
FROM dual;
12345
Using {m
,}, you can leave the upper end of
a range unbounded:
SELECT REGEXP_SUBSTR(
'1234567890','[[:digit:]]{3,}')
FROM dual;
1234567890
Get Oracle Regular Expressions Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.