V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
paloalto
V2EX  ›  问与答

请教关于正则匹配的问题

  •  
  •   paloalto · Sep 16, 2010 · 4600 views
    This topic created in 5715 days ago, the information mentioned may be changed or developed.
    小弟以前没学过写代码,后来google了一下发现
    [^\x00-\xff]用来匹配中文
    [a-zA-Z0-9]用来匹配英文和数字

    如果需要同时匹配中文、英文、数字,代码该怎么写呢?
    1 replies    1970-01-01 08:00:00 +08:00
    fay
        1
    fay  
       Sep 16, 2010
    [^\x00-\xff]这个严格来说不是匹配中文,而是排除ascii码为0-255的字符(就是西文字符)以外的多字节字符,例如中文、日文、韩文。你可以想想哪些字符不需要匹配,然后用^来解决。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2971 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 06:33 · PVG 14:33 · LAX 23:33 · JFK 02:33
    ♥ Do have faith in what you're doing.