-1

I have a company name field in my app. The company might be Russian or from any other country.

If the company is Russian I need to restrict user input so that he can type any chars except latin letters.

If the company is not Russian then I need to restrict user input so that he can type any chars except Russian.

So I actually have such regexps:

latinChars: /^[a-zA-Z][a-zA-Z\s-]*$/
cyrillicChars: /^[а-яА-Яё][а-яА-Яё\s-]*$/

But I cannot figure out how to exclude characters. Like, I tried using (?!...) operator without success.

Victor
  • 5,073
  • 15
  • 68
  • 120
  • Exclude is NOT include. How you check included charaters? Use that condition with negative `!` for check characters excluded – Darth Aug 11 '20 at 13:37

1 Answers1

0

You can use the [^] operator to match anything except what's enclosed in it.

Example :

^[^A-Za-z]*$

Will match anything except all latin letters.

Test it here.

You can apply this to the range of Russian chars.

totok
  • 1,436
  • 9
  • 28