?? For example, the following is the Nineth chapter of MySQL must be known to start:
The normal form is used to match a particular character set. MySQL provides preliminary support for the regular form through the WHERE clause.
Keywordregexp is used to denote what is followed as a form of processing.
(.) is a symbol of a regular expression that matches a random character:
Mysql> Select Prod_name, from Products, where Prod_name regexp '. ORDER by prod_name;+ --------------+| Prod_name |+--------------+| JetPack 1000 | | JetPack |+--------------+2 rows in Set (0.14 sec)
| match character:
Represents one of the matches among
Mysql> Select Prod_name, from Products, where Prod_name REGEXP ' 1000|2000 ' ORDER by Prod_n ame;+--------------+| Prod_name |+--------------+| JetPack 1000 | | JetPack |+--------------+2 rows in Set (0.00 sec)
[] Match: Matches one of several characters
2 rows in Set (0.00 sec) mysql> Select Prod_name, from Products, where Prod_name regexp ' [123] Ton '
->, +-------------+| Prod_name |+-------------+| 1 ton Anvil | | 2 ton anvil |+-------------+2 rows in Set (0.00 sec)
Mysql> Select Prod_name from Products where prod_name regexp ' [1-5] Ton '; +--------------+| Prod_name |+--------------+|. 5 Ton Anvil | | 1 ton Anvil | | 2 Ton anvil |+--------------+3 rows in set (0.02 s Ec
(^) Negative match:
Mysql> Select Prod_name from Products where prod_name regexp ' [^1-3] Ton '; +--------------+| Prod_name |+--------------+|. 5 ton Anvil |+--------------+1 row in Set (0.00 sec)
To match Special characters, you must use \ \ as the leading.
Mysql> Select Prod_name from Products where prod_name regexp ' \ \. '; +--------------+| Prod_name |+--------------+|. 5 ton Anvil |+--------------+1 row in Set (0.00 sec)
Match character class:
Mysql> Select Prod_name from Products where prod_name REGEXP ' \ \ ([0-9] sticks?\\) ' ORDER by prod_name;+---------------- +| Prod_name |+----------------+| TNT (1 stick) | | TNT (5 sticks) |+----------------+2 rows in Set (0.05 sec) mysql> Select Prod_name from Products where Prod_name REGEXP ' [[:d igit:]]{4} ' ORDER by prod_name;+--------------+| Prod_name |+--------------+| JetPack 1000 | | JetPack |+--------------+2 rows in Set (0.00 sec)
How to use Locators:
Mysql> Select Prod_name, from Products, where Prod_name REGEXP ' ^[0-9\\.] ' ORDER BY prod_name;+--------------+| Prod_name |+--------------+|. 5 Ton Anvil | | 1 ton Anvil | | 2 Ton anvil |+--------------+3 rows in Set (0.00 s Ec
These are the methods used by MySQL in the form of expressions.