MySQL

Whitespace Metacharacters

Metacharacter Description

\\f

Form feed

\\n

Line feed

\\r

Carriage return

\\t

Tab

\\v

Vertical tab


Matching \

To Match \ To match the backslash character itself (\), you would need to use \\\.

\ or \\? Most regular expression implementation use a single backslash to escape special characters to be able to use them as literals. MySQL, however, requires two backslashes (MySQL itself interprets one and the regular expression library interprets the other).

Matching Character Classes

There are matches that you'll find yourself using frequently, digits, or all alphabetical characters, or all alphanumerical characters, and so on. To make working with these easier, you may use predefined character sets known as character classes. Following table lists the character classes and what they mean.

Character Classes

Class Description

[:alnum:]

Any letter or digit, (same as [a-zA-Z0-9])

[:alpha:]

Any letter (same as [a-zA-Z])

[:blank:]

Space or tab (same as [\\t ])

[:cntrl:]

ASCII control characters (ASCII 0 through 31 and 127)

[:digit:]

Any digit (same as [0-9])

[:graph:]

Same as [:print:] but excludes space

[:lower:]

Any lowercase letter (same as [a-z])

[:print:]

Any printable character

[:punct:]

Any character that is neither in [:alnum:] nor [:cntrl:]

[:space:]

Any whitespace character including the space (same as [\\f\\n\\r\\t\\v ])

[:upper:]

Any uppercase letter (same as [A-Z])

[:xdigit:]

Any hexadecimal digit (same as [a-fA-F0-9])