0

I'm trying to use Regex validation in my Laravel 5.4 project.

I would like two possible strings to be valid. For example, I will only accept "Michael" or "Mike." I want them both to be valid.

I have been using https://regex101.com/ to help me figure this out. However, what works there does not work on my project.

Here is my code: 'name' => 'required|regex:/^(Michael|Mike)$/',

Here is the error:

(1/1) ErrorException
preg_match(): No ending delimiter '/' found

So, it seems like PHP is reading this as if the | is a new request and therefore can't find the end of the first regex request /. Is there anyway to make sure that it reads that this is an either/or statement within the ()?

Any idea what I'm doing wrong?

Thanks!

Brad Ahrens
  • 4,864
  • 5
  • 36
  • 47

0 Answers0