Regex character limit not working with unicode limitaion

I’m writing JavaScript.
I got this regex which does not allow Russian or Arabic chars.

/[^\u0621-\u064A]+[^\u0401\u0451\u0410-\u044f]/

I need to limit characters to up to 10.
I tried to add {0,10}$ as suggested in this post and others:

/[^\u0621-\u064A]+[^\u0401\u0451\u0410-\u044f]{0,10}$/ // try 1
/[^\u0621-\u064A]{0,10}$[^\u0401\u0451\u0410-\u044f]/ // try 2

None of them working.
The a-z example in the post (/^[a-z]{0,10}$/) is working,
so it may ne related to the unicode part.

What am I missing?

>Solution :

How about a group:

No need for the +

/^([^\u0621-\u064A\u0401\u0451\u0410-\u044f]){0,10}$/

Leave a Reply