Regular expression to allow character set and forbid others

I want to restrict user access to the following special characters in the field:

œçşÇŞ
ğĞščřŠŘŇĚŽĎŤČňěž
ůŮ
İťı
—¿ „" * @
Newline
Carriage return

A few more will be added to this list, but in the end I will have a complete list of restrictions.

But he can enter some foreign characters, such as äöüÄÖÜÿïetc. in addition to alphanumeric characters, ordinary special characters, etc.

Is there an easy way to create a regex for this. Adding as many characters to an invalid list as

[^ œçşÇŞ ğĞščřŠŘŇĚŽĎŤČňěž ůŮ İ ť ı - ¿„" * @] +

doesn't seem to work.

And I do not have a complete list of valid characters. This would be too long, even if I try to get it and include all the characters, for example:

~`!#$%^&()[]{};':",.

.

+3
5

, "" . ?

\A[^œçşÇŞ ğĞščřŠŘŇĚŽĎŤČňěž ůŮ İ ť ı — ¿ „ " * @]+\z
+1

, :

[œçşÇŞ ğĞščřŠŘŇĚŽĎŤČňěž ůŮ İ ť ı]

( , !).

- , .

, , , , :

[^œçşÇŞ ğĞščřŠŘŇĚŽĎŤČňěž ůŮ İ ť ı]*
+1

, , - ? , .NET .Contains().

, , , . , "" .

+1

,    .

( , , ~ `! # $% ^ &() [] {}; ':",. < > )

, , ? , . , . , , , . .

, Unicode, , , , - . , , a-z, .

, , [^ œçşÇŞ ĞĞščřŠŘŇĚŽĎŤČňěž ůŮ İ ť ı - ¿"" * @] *. , , , .

, [^ œçşÇŞ ğĞščřŠŘŇĚŽĎŤČňěž ůŮ İ ť ı - ¿"" * @] +, , .

. ? , , .

0

, , . , "a" "z", .

[^a-z]

, , , , , . , , , , . , , .

, escape- , .

Find them for Perl RE here , find "Character Classes and Other Special Screens." This may allow you to have a shorter expression like this.

[^\w\d  ..other individual chars..  ]
0
source

Source: https://habr.com/ru/post/1705719/


All Articles