简体   繁体   English

.Net Regex匹配字符串中包含任何非ASCII字符

[英].Net Regex that Matches Strings With Any non-ASCII char in it

Looking for some black magic that will match any string with "weird" characters in it. 寻找一些黑魔法,它将匹配任何字符串中的“奇怪”字符。 Standard ASCII characters are fine. 标准的ASCII字符很好。 Everything else isn't. 其他一切都不是。

This is for sanitizing various web forms. 这用于清理各种Web表单。

This gets anything out of the ASCII range 这会从ASCII范围中获得任何结果

[^\x00-\x7F]

There are still some "weird" characters like x00 (NULL), but they are valid ASCII. 仍然有一些像“ x00 (NULL)”这样的“怪异”字符,但它们是有效的ASCII。
For reference, see the ASCII table 有关参考,请参阅ASCII表

[^\\p{IsBasicLatin}]用于要求的内容, [^\\x00-\\x7F]用于[^\\x00-\\x7F]自我文档,或者\\p{C}用于清除格式化程序和控件而不会损害其他非ASCII(以及更精简)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM