Database Reference
In-Depth Information
POSIX class What the class matches
[:alnum:] Alphabetic and numeric characters
[:alpha:] Alphabetic characters
[:blank:] Whitespace (space or tab characters)
[:cntrl:] Control characters
[:digit:] Digits
[:graph:] Graphic (nonblank) characters
[:lower:] Lowercase alphabetic characters
[:print:] Graphic or space characters
[:punct:] Punctuation characters
[:space:] Space, tab, newline, carriage return
[:upper:] Uppercase alphabetic characters
[:xdigit:] Hexadecimal digits ( 0-9 , a-f , A-F )
POSIX classes are intended for use within character classes, so use them within square
brackets. The following expression matches values that contain any hexadecimal digit
character:
mysql> SELECT name, name REGEXP '[[:xdigit:]]' FROM metal;
+----------+----------------------------+
| name | name REGEXP '[[:xdigit:]]' |
+----------+----------------------------+
| gold | 1 |
| iron | 0 |
| lead | 1 |
| mercury | 1 |
| platinum | 1 |
| tin | 0 |
+----------+----------------------------+
Regular expressions can specify alternations using this syntax:
alternative1 | alternative2 |...
An alternation is similar to a character class in the sense that it matches if any of the
alternatives match. But unlike a character class, the alternatives are not limited to single
characters. They can be multiple-character strings or even patterns. The following al‐
ternation matches strings that begin with a vowel or end with er :
mysql> SELECT name FROM metal WHERE name REGEXP '^[aeiou]|d$';
+------+
| name |
+------+
| gold |
| iron |
| lead |
+------+
 
Search WWH ::




Custom Search