Match either zero or one a character: a? : Zero or One « Regular Expressions « MySQL Tutorial






mysql>
mysql> SELECT 'ABC' REGEXP '^Aa?C';
+----------------------+
| 'ABC' REGEXP '^Aa?C' |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT 'ABC' REGEXP '^ABa?C';
+-----------------------+
| 'ABC' REGEXP '^ABa?C' |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT 'ABC' REGEXP '^Ba?C';
+----------------------+
| 'ABC' REGEXP '^Ba?C' |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.00 sec)

mysql>








24.14.Zero or One
24.14.1.Match either zero or one a character: a?
24.14.2.Get first name with zero or one J character: J?