Suppose we have number 852 1111 2222 in format .What is the Laravel validation for this number(regular expression) with symbol and allow space between number?
'phone_number' => 'required|regex:/(^[0-9 ] $) /',
CodePudding user response:
Regular expression will be good example for you as you the format of phone number won't change you cant take this regex patter as example
'phone_number' => 'required|regex:/^\ \d{3}\s\d{4}\s\d{4}$/',
In case the phone number prefix doesn't change you can include it directly in the pattern like this
'phone_number' => 'required|regex:/^\ 852\s\d{4}\s\d{4}$/',
Here is the link to regex101
