I have a question. How should look a regex for the following words: +23456745678 or +29845281058, (with comma) I tried but no result:
if (!preg_match('#^\+[0-9]{11}$#',$string)) {
return ("Msisdn $string is incorrect!");
break;
}
Always I get this error. Please help me. Thx in advance
The pattern should be:
'/\+[0-9]{11},?/'
The ^ in the beginning and $ at the end stand for beginning and end of line, which I am not sure if you really want there (my guess is not).
Test it here: http://www.phpliveregex.com/p/78v
Another option is to use \\d for digit
'/\+\d{11},?/'
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.