Oracle 5.0 Reference Manual page 921

Table of Contents

Advertisement

de|abc
Match either of the sequences
mysql>
SELECT 'pi' REGEXP 'pi|apa';
mysql>
SELECT 'axe' REGEXP 'pi|apa';
mysql>
SELECT 'apa' REGEXP 'pi|apa';
mysql>
SELECT 'apa' REGEXP '^(pi|apa)$';
mysql>
SELECT 'pi' REGEXP '^(pi|apa)$';
mysql>
SELECT 'pix' REGEXP '^(pi|apa)$';
(abc)*
Match zero or more instances of the sequence abc.
mysql>
SELECT 'pi' REGEXP '^(pi)*$';
mysql>
SELECT 'pip' REGEXP '^(pi)*$';
mysql>
SELECT 'pipi' REGEXP '^(pi)*$';
• {1},
{2,3}
or
notation provides a more general way of writing regular expressions that match many
{n}
{m,n}
occurrences of the previous atom (or "piece") of the pattern.
a*
Can be written as a{0,}.
a+
Can be written as a{1,}.
a?
Can be written as a{0,1}.
To be more precise,
matches
a.
a{m,n}
m
and
must be in the range from
m
n
given,
must be less than or equal to n.
m
mysql>
SELECT 'abcde' REGEXP 'a[bcd]{2}e';
mysql>
SELECT 'abcde' REGEXP 'a[bcd]{3}e';
mysql>
SELECT 'abcde' REGEXP 'a[bcd]{1,10}e';
• [a-dX],
[^a-dX]
Matches any character that is (or is not, if ^ is used) either a, b, c,
other characters forms a range that matches all characters from the first character to the second.
For example,
[0-9]
follow the opening bracket [. To include a literal
character that does not have a defined special meaning inside a
mysql>
SELECT 'aXbc' REGEXP '[a-dXYZ]';
mysql>
SELECT 'aXbc' REGEXP '^[a-dXYZ]$';
mysql>
SELECT 'aXbc' REGEXP '^[a-dXYZ]+$';
mysql>
SELECT 'aXbc' REGEXP '^[^a-dXYZ]+$';
mysql>
SELECT 'gheis' REGEXP '^[^a-dXYZ]+$';
mysql>
SELECT 'gheisa' REGEXP '^[^a-dXYZ]+$';
[.characters.]
Regular Expressions
or abc.
de
matches exactly
a{n}
n
through
instances of a, inclusive.
n
to
0
RE_DUP_MAX
matches any decimal digit. To include a literal
901
-> 1
-> 0
-> 1
-> 1
-> 1
-> 0
-> 1
-> 0
-> 1
and
m
n
instances of a.
matches
a{n,}
(default 255), inclusive. If both
-> 0
-> 1
-> 1
or X. A
d
]
character, it must be written first or last. Any
-
pair matches only itself.
[]
-> 1
-> 0
-> 1
-> 0
-> 1
-> 0
are integers.
or more instances of
n
and
m
n
character between two
-
character, it must immediately
are

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents