I validate the form with a laravel validator, swear at 'vk_url' => 'regex:/^(http(s)?:\/\/)?(www\.)?vk\.com\/(\w|\d)+?\/?$/' , namely:

 ErrorException in Validator.php line 1805: preg_match(): No ending delimiter '/' found 

An expression like a standard form, I have already tried many options. In what form does the validator accept regulars, how should this expression be altered?

  • 2
    Here most likely you need to pass this parameter as an array. By the way, here (\w|\d)+? = \w+ - Wiktor Stribiżew
  • @ WiktorStribiżew, thank you, replaced by \w+ and it worked - rival.dm

1 answer 1

In Laravel there are certain features of working with regulars. Most often there are spaces exactly with the OR operator, since the characters | used by Laravel itself to transfer an array of parameters.

This is described in the documentation (in English): "When using regular expressions, it may be necessary to specify the rules as an array in the mixture of separators | , especially if this symbol is used in the regular expression itself." (in my free translation).

In your particular case, you can simply get rid of this operator:

 'vk_url' => 'regex:/^(http(s)?:\/\/)?(www\.)?vk\.com\/\w+\/?$/' ^^^^ 

since \w finds numbers too.