O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Regular expressions

You can use regular expressions in the WHERE clause by using the RLIKE or REGEXP operators. There are many ways to use REGEXP, refer to https://dev.mysql.com/doc/refman/8.0/en/regexp.html for more examples:

Expression

Description

*

Zero or more repetitions

+

One or more repetitions

?

Optional character

.

Any character

\.

Period

^

Starts with

$

Ends with

[abc]

Only a, b, or c

[^abc]

Neither a, b, nor c

[a-z]

Characters a to z

[0-9]

Numbers 0 to 9

^...$

Starts and ends

\d

Any digit

\D

Any non-digit character

\s

Any whitespace

\S

Any non-whitespace character

\w

Any alphanumeric character

\W

Any non-alphanumeric ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required