Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript regex character exclusion

I have a such js regex:

/^[a-zA-ZęóąśłżźćńĘÓĄŚŁŻŹĆŃ]+$/

and now I would like to exclude from a-zA-Z letters like QVXqvx. How the syntax of this regex should be changed?

I tried but no luck. Please help me.

Thanks in advance

like image 740
Mariusz Grodek Avatar asked May 27 '12 22:05

Mariusz Grodek


People also ask

What is ?! In regex?

Definition and Usage. The ?! n quantifier matches any string that is not followed by a specific string n. Tip: Use the ?= n quantifier to match any string that IS followed by a specific string n.

Why * is used in regex?

- a "dot" indicates any character. * - means "0 or more instances of the preceding regex token"

How do you match a space in regex?

\s stands for “whitespace character”. Again, which characters this actually includes, depends on the regex flavor. In all flavors discussed in this tutorial, it includes [ \t\r\n\f]. That is: \s matches a space, a tab, a carriage return, a line feed, or a form feed.


1 Answers

You can still do ranges, but you'll have to do ranges that exclude those letters, so something like A-PR-UWYZ

like image 113
James Manning Avatar answered Nov 15 '22 05:11

James Manning