Wednesday, 25 July 2018

MySQL: Search String using Regular Expressions (REGEXP)

A regular expression is a special text or string which is describing a different search pattern.
When we are validating email addresses, IP-Addresses and any other special string, we should use a regular expression for perfect pattern matching.
Using regular expressions, you can check different special characters, numbers, lower and capital letters.
MySQL provides REGEXP for performing pattern matching in WHERE clause.
Some of the few examples are here:
Create a table with sample data:
Check for numbers:
Check for lower and upper letters:
Check for all symbols:
Check for all the combinations:

0 comments:

Post a Comment