Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What am I missing?

>Solution :

How about a group:

No need for the +

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading