Level 50
Try this..
'name' => ['required', 'regex:/^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,() ]+$/']
5 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I dont use regex very often, so am not too familiar with it. I am trying to validate a input, and only want to allow a-z, A-Z, 0-9, spaces and a bunch of french characters. I dont want to allow < > quotes, script tags, etc..
Here is what i have:
'name' => ['required', 'regex:^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,()]+$^']
Thing is, it works some times and not other. If you put < at the front of the data, it doesn't catch it. But catches it if its at the end.
Thanks.
Try this..
'name' => ['required', 'regex:/^[A-ZÀÂÇÉÈÊËÎÏÔÛÙÜŸÑÆŒa-zàâçéèêëîïôûùüÿñæœ0-9_.,() ]+$/']
Please or to participate in this conversation.