Database Reference
In-Depth Information
To match special characters they must be preceded by \\ . So, \\- means find
- and \\. means find .
Input
SELECT vend_name
FROM vendors
WHERE vend_name REGEXP '\\.'
ORDER BY vend_name;
Output
+--------------+
| vend_name |
+--------------+
| Furball Inc. |
+--------------+
Analysis
That worked. \\. matches . , and so only a single row was retrieved. This pro-
cess is known as escaping , and all characters that have special significance within
regular expressions must be escaped this way. This includes . , | , [] , and all the
other special characters used thus far.
\\ is also used to refer to metacharacters (characters that have specific mean-
ings), as listed in Table 9.1.
Table 9.1 Whitespace Metacharacters
Metacharacter
Description
\\f
Form feed
\\n
Line feed
\\r
Carriage return
\\t
Tab
\\v
Vertical tab
Tip
To Match \ To match the backslash character itself ( \ ), you need to use \\\ .
Note
\ or \\ ? Most
regular expression implementations use a single backslash to escape
special characters to be able to use them as literals. MariaDB, however, requires two
backslashes (MariaDB itself interprets one, and the regular expression library interprets
the other).
 
 
Search WWH ::




Custom Search