Regex exception for one letter does not fire. JS

Viewed 32

I have a simple JS validation in the form of a red line under the input. It just shows where the error is, the main validation takes place on the server. So, I'm excluding all symbols except those allowed. I also added one language to the exception, which has most of the letters from the English alphabet, with the exception of a few. All of those letters pass validation with the exception of ə. It's funny that the lowercase only exception doesn't work for it. At the top, everything works fine.

The code for this letter: u04D9.

And here is the function itself:

str.replace(/[^\u0400-\u04FF\u00C7\u018F\u011E\u0049\u0130\u00D6\u015E\u00DC\u00E7\u04D9\u011F\u0131\u0069\u00F6\u015F\u00FC\w@.?()+"/,:;*%!№$#=-]+/gu, '');

Are there any suggestions how this can be solved?

1

2

1 Answers

\u04D9 is a CYRILLIC SMALL LETTER SCHWA. The character you have identified is a LATIN SMALL LETTER SCHWA with the \u0259 code. You need to add it to the regex in order to "catch" it.

However, there are quite a few characters that look similar to chars like ə:

Ə ‎018F LATIN CAPITAL LETTER SCHWA
ǝ ‎01DD LATIN SMALL LETTER TURNED E
ə ‎0259 LATIN SMALL LETTER SCHWA
Ә ‎04D8 CYRILLIC CAPITAL LETTER SCHWA
ә ‎04D9 CYRILLIC SMALL LETTER SCHWA
ᵊ ‎1D4A MODIFIER LETTER SMALL SCHWA
ₔ ‎2094 LATIN SUBSCRIPT SMALL LETTER SCHWA

It seems reasonable to add \u018F\u01DD\u0259\u04D8\u04D9\u1D4A\u2094 to the list of the chars.

Related