I'm not very good at regex but using the link site I was able to generate an expression that accepts:
- Do not accept special characters
- You can have up to 5 words separated by whitespace
The generated regex: (^\w{0,30}){1}(\s?(\w{0,30})){1,4}
I'm trying to use it in a Request class as a Rule regex
public function rules()
{
return [
'name' => 'required|max:255|unique:classes,name|regex:/(^\w{0,30}){1}(\s?(\w{0,30})){1,4}/m',
'description' => 'max:255',
];
}
This is not being validated, anything I enter into the 'name' field the system accepts.