Oracle 5.0 Reference Manual page 920

Table of Contents

Advertisement

Warning
The
so they are not multi-byte safe and may produce unexpected results with
multi-byte character sets. In addition, these operators compare characters by
their byte values and accented characters may not compare as equal even if
a given collation treats them as equal.
A regular expression describes a set of strings. The simplest regular expression is one that has no
special characters in it. For example, the regular expression
Nontrivial regular expressions use certain special constructs so that they can match more than one
string. For example, the regular expression
word.
As a more complex example, the regular expression
Baaaaas, Bs, and any other string starting with a B, ending with an s, and containing any number of
or
characters in between.
n
A regular expression for the
and constructs:
^
Match the beginning of a string.
mysql>
SELECT 'fo\nfo' REGEXP '^fo$';
mysql>
SELECT 'fofo' REGEXP '^fo';
$
Match the end of a string.
mysql>
SELECT 'fo\no' REGEXP '^fo\no$';
mysql>
SELECT 'fo\no' REGEXP '^fo$';
.
Match any character (including carriage return and newline).
mysql>
SELECT 'fofo' REGEXP '^f.*$';
mysql>
SELECT 'fo\r\nfo' REGEXP '^f.*$';
a*
Match any sequence of zero or more
mysql>
SELECT 'Ban' REGEXP '^Ba*n';
mysql>
SELECT 'Baaan' REGEXP '^Ba*n';
mysql>
SELECT 'Bn' REGEXP '^Ba*n';
a+
Match any sequence of one or more
mysql>
SELECT 'Ban' REGEXP '^Ba+n';
mysql>
SELECT 'Bn' REGEXP '^Ba+n';
a?
Match either zero or one
mysql>
SELECT 'Bn' REGEXP '^Ba?n';
mysql>
SELECT 'Ban' REGEXP '^Ba?n';
mysql>
SELECT 'Baan' REGEXP '^Ba?n';
Regular Expressions
[899]
and
REGEXP
RLIKE
hello|word
[899]
operator may use any of the following special characters
REGEXP
characters.
a
characters.
a
character.
a
900
[899]
operators work in byte-wise fashion,
matches
hello
matches either the string
matches any of the strings Bananas,
B[an]*s
-> 0
-> 1
-> 1
-> 0
-> 1
-> 1
-> 1
-> 1
-> 1
-> 1
-> 0
-> 1
-> 1
-> 0
and nothing else.
hello
or the string
hello
a

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents