.Net Regex ValidationExpression ASCII

Does anyone know the correct Regex expression to output to ValidationExpression to make sure that my users enter only ASCII characters?

<asp:RegularExpressionValidator id="myRegex" runat="server" ControlToValidate="txtName" ValidationExpression="???" ErrorMessage="Non-ASCII Characters" Display="Dynamic" /> 
+1
source share
2 answers

One thing you might want to keep an eye on is that the bottom of the ascii table has a lot of control characters that can cause funky results. Here the expression that I use allows only "not funky":

^ ([^ \ x0D \ x0a \ x20- \ x7E \ ] *) $

+2
source

If you want to match the possible values ​​0x00 - 0xff ASCII, you can use this regular expression (.NET).

 ^([\x00-\xff]*)$ 
0
source

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


All Articles