[英]Regular Expression validation not working for Chinese culture in ASP.Net
I have a regular expression validator with client-side validation disabled in an ASP.Net change. 我有一个正则表达式验证器,在ASP.Net更改中禁用了客户端验证。 The regular expression being used for this validator is as below and it is validating input into a
Product Description
multi-line text box. 用于此验证器的正则表达式如下所示,它正验证到“
Product Description
多行文本框中的输入。
Expression="^[\\p .,;'\-(0-9)\(\)\[\]]+$"
The culture for this ASP.Net app is Chinese as specified in web config. 此ASP.Net应用程序的区域性是Web配置中指定的中文。
<globalization uiCulture="zh" culture="zh-CHT" />
The following input into Product Description
text box in same ASP.Net page is always failing. 在同一ASP.Net页的“
Product Description
文本框中的以下输入始终失败。 I am trying to match any one of these: chinese langauge character or period or comma or semi-colon or single quote or digits or round/square brackets. 我正在尝试匹配以下任意一项:中文字符或句号或逗号,分号或单引号或数字或圆/方括号。
Question : What is in the regular expression that is causing this input text to fail and how can I change it to satisfy the matching requirements? 问题 :正则表达式中有什么导致此输入文本失败,如何更改它以满足匹配要求?
(1)降低庫存過程 (2)增加了吞吐量(1)降低庫存過程 (2)增加了吞吐量(1)降低庫存過程 (2)增加了吞吐量(1)降低庫存過程 (2)增加了吞吐量
In .NET regex, the one that works on server side, you can make use of Unicode categories . 在.NET正则表达式中,它可以在服务器端运行,可以使用Unicode类别 。
^[\p{L}\p{M}\p{N}\s\p{P}]+$
So, the character class matches: 因此,字符类匹配:
\\p{L}
- Unicode letters \\p{L}
-Unicode字母 \\p{M}
- diacritic marks \\p{M}
-变音符号 \\p{N}
- numbers \\p{N}
-数字 \\s
- whitespace \\s
空格 \\p{P}
- punctuation. \\p{P}
-标点符号。 Note these Unicode categories won't work on client-side where your Englsh UI culture validation takes place. 请注意,这些Unicode类别不适用于进行Englsh UI文化验证的客户端。 You can use your fixed expression there:
您可以在此处使用固定表达式:
^[a-zA-Z .,;'\-0-9()\[\]]+$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.