Database Reference
In-Depth Information
Table 11.2 Regular Expression Elements
Element Description
Matches item a or b (a|b)
|
Looks for matches at the beginning of the string
^
Looks for matches at the end of the string
$
Matches any single character
.
Matches preceding item zero or more times
*
Matches preceding item one or more times
+
Makes the preceding item optional
?
Matches the preceding item exactly n times
{n}
Matches the contents exactly
( )
Matches any of the characters in the content, such as [0-9]
[ ]
Matches a nonalphanumeric character named x
\\x
Matches an escape string \y
\\y
To illustrate the use of these elements, the following SELECT statements include
examples in which the comparisons are True or False .
/* matches x or y ('x|y')*/
SELECT '123a567' ˜ '23|b' /* returns True */
SELECT '123a567' ˜ '32|b' /* returns False */
/* matches the beginning of the string */
SELECT '123a567' ˜ '^123a' /* returns True */
SELECT '123a567' ˜ '^123a7' /* returns False */
/* matches the end of the string */
SELECT '123a567' ˜ 'a567$' /* returns True */
SELECT '123a567' ˜ '27$' /* returns False */
/* matches any single character */
SELECT '123a567' ˜ '2.a' /* returns True */
SELECT '123a567' ˜ '2..5' /* returns True */
SELECT '123a567' ˜ '2…5' /* returns False */
/* matches preceding character zero or more times */
SELECT '123a567' ˜ '2*'
/* returns True */
Search WWH ::




Custom Search