ebukz's avatar

Facebook Profile URL Regex Problem

So i am using a class to validate a form request for a facebook profile

 public function rules()
    {
        return [
            EditProfilePage::$facebook_profile_url => 'url|regex:https://www.facebook.com/.+',
        ];
    }

Using the above regex returns the following error

preg_match(): Delimiter must not be alphanumeric or backslash

Does anyone know a suitable regex I can use to accomplish this. A facebook profile url can be in the following form:

https://www.facebook.com/user.name https://www.facebook.com/username

0 likes
1 reply
nutracelle's avatar
Level 2

As far as I know you have to write out the full regex when using Form Validation, like the below example.

return [
    EditProfilePage::$facebook_profile_url => 'url|regex:/http(?:s):\/\/(?:www\.)facebook\.com\/.+/i'
];

You might also try including the rules as an array instead of a piped string.

1 like

Please or to participate in this conversation.