in my laravel app I have following regex validation,
'modelname' => 'required|regex:/^[A-Za-z0-9. -]+$/|unique:modols|max:255'
now I need ad ' symbol also to this modelname how can I do this?
in my laravel app I have following regex validation,
'modelname' => 'required|regex:/^[A-Za-z0-9. -]+$/|unique:modols|max:255'
now I need ad ' symbol also to this modelname how can I do this?
You just need to add '
to your regex character class:
'modelname' => 'required|regex:/^[A-Za-z0-9. \'-]+$/|unique:modols|max:255'
Here ------^
Bear in mind that your regex have the -
at the end of the character class, if not it will be treated as character class range, if so you will have to escape it with \-