I have a laravel validation rule something like this
public function rules(){
return [
'title' => 'required|max:100',
'featured_image' => 'required|max:100|regex:(\d)+.(?:jpe?g|png|gif)',
];
}
I have a txt field where i dynamically add an image name, something like this (8123123123.jpg OR 234234234.png). If the text field doesn't have this pattern i want to show an error.
Now this regex does work in http://regexr.com/ but in laravel it doesn't. So basically it should look for digits as file name and should end with .jpg or .png
Any help is appreciated
\.
. Additionally, you might want to make sure, that the jpg/png/gif part is at the very end of the string, so combined, this would be:\.(?:jpe?g|png|gif)$
– Jan'featured_image' => array('required', 'max:100', 'regex:/[0-9]+[.](jpe?g|png|gif)/')
– Wiktor Stribiżew