开发者

Javascript regex to reject non ASCII-US characters

^[^\x00-\x1F\x7F-\xFF]+$

This regex will properly fa开发者_如何学Pythonil 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.


Hmm... instead of rejecting byte ranges, try matching actual Unicode characters, e.g.:

^[\u0020-\u007e]+$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜