WHAT'S NEW?
Loading...

Regex in Query of MySQL

A query to obtain phone number of users from users table through regular expression matching:
SELECT phone_number FROM users WHERE phone_number REGEXP '^[0-9]{10}$'
The above is a query to match 10 digit number. 0 is allowed as first digit of number, this is quite not useful in case of mobile number. The regular expression can be modified as '^98[0-9]{8}$' for mobile numbers like 9800456745

0 comments:

Post a Comment