preg_match(): No ending delimiter ‘^’ found Laravel Full Name Validation Rules

preg_match(): No ending delimiter ‘^’ found Laravel Full Name Validation Rules

The regex caused the error during validation check on Alphaspace Rules regular expression for below regex:

return preg_match('^[a-zA-Z\s]+$',$value);

To fix the issue add delimiters to regex, below is the right regex:

public function passes($attribute, $value) {

return preg_match('/^[a-zA-Z\s]+$/',$value);

}

# note / slash in start and end of the regex

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *