Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Regex exclude brackets

I'm trying to make a simple validation in JavaScript & PHP (for double checking) by using regex. I just want to check that the names will be allowed if there is at least two of these characters:

letters + accents + spaces + simple quotes + dash

^[aA-zZ\u00C0-\u017F- \']{2,}$

Regular expression visualization

Debuggex Demo

But actually, brackets are allowed in my regex pattern (don't know why), and I'd like them to be excluded, how can I do that ?

I know that \u is not allowed in PCRE-like regular expressions.

Thanks

like image 241
Lazao Avatar asked Dec 14 '25 13:12

Lazao


1 Answers

The square brackets are between A and z I think you meant to have a-zA-Z in your regex.

like image 104
Musa Avatar answered Dec 17 '25 05:12

Musa