preg_match():Compilation failed in my code.
Preg match expression in my controller is
'phoneno' => 'required|regex:/(+92)[0-9]{10}/',
Please tell me what is wrong with the regex.
You need to escape the +
character. You want to match on a phone number starting with +92
. But the +
character means that it expects 1 or more of the preceding character . Which in this case you don't want.
So in short, change it to this:
/(\\+92)[0-9]{10}/
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.