admin管理员组文章数量:1403506
^[^\x00-\x1F\x7F-\xFF]+$
This regex will properly fail to match a string that contains non-printing (hex 00-1f) or ASCII extended characters (hex 80-FF), but, unlike PHP, lets non-ASCII utf-8 characters pass. (eg. 日本واستقرارهहिन्दीދިވެހިބަސްગુજરાતી한)
Looking at the wikipedia page on UTF-8 all of those should fall in the 80-ff range. Does anyone know what I'm missing?
Also, if you could explain how to ignore quoted text, you would be my hero forever.
^[^\x00-\x1F\x7F-\xFF]+$
This regex will properly fail to match a string that contains non-printing (hex 00-1f) or ASCII extended characters (hex 80-FF), but, unlike PHP, lets non-ASCII utf-8 characters pass. (eg. 日本واستقرارهहिन्दीދިވެހިބަސްગુજરાતી한)
Looking at the wikipedia page on UTF-8 all of those should fall in the 80-ff range. Does anyone know what I'm missing?
Also, if you could explain how to ignore quoted text, you would be my hero forever.
Share Improve this question edited Aug 12, 2010 at 8:34 Greg asked Aug 12, 2010 at 8:23 GregGreg 7,9228 gold badges45 silver badges69 bronze badges1 Answer
Reset to default 9Hmm... instead of rejecting byte ranges, try matching actual Unicode characters, e.g.:
^[\u0020-\u007e]+$
本文标签: Javascript regex to reject non ASCIIUS charactersStack Overflow
版权声明:本文标题:Javascript regex to reject non ASCII-US characters - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744384072a2603650.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论