MySQL: Search String using Regular Expressions (REGEXP)

A regular expression is a special text or string which is describing a different search pattern.

Generally, when we are validating email addresses, IP-Addresses and any other special string, we should use regular expression for perfect pattern matching.

Using regular expressions, you can check different special character, numbers, lower and capital letters.

MySQL provides REGEXP for performing pattern matching in WHERE clause.
Some of the few examples are here:

First, create a table with sample data:

Check for numbers:

Check for lower and upper letters:

Check for all symbols:

Check for all the combinations:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz