I need to match phone numbers that :
start with 010 or 012 or 016 or 019
Consist of 10 numbers exactly
Can you please help me on how to match numbers using PHP and regex?
return preg_match('/^01[0269]\\d{7}$/', $theStringToTest);
This will match 0, 1, one of (0, 2, 6, 9), and then any 7 numbers (3+7==10). The ^
means start of string and $
means end of string.
使用此正则表达式
/\b(010|012|016|019)[0-9]{7}\b/g
我想我会使用^01[0269][0-9]{7}$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.