Reputation: 362
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.
Upvotes: 0
Views: 2043
Reputation: 21057
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}/
Upvotes: 3