TonyGong
V2EX  ›  问与答

请教正则表达式大神,匹配英文单词,小撇号的处理

  •  
  •   TonyGong · Jul 10, 2019 · 2556 views
    This topic created in 2532 days ago, the information mentioned may be changed or developed.

    //特殊处理中英文 小撇' ’ public static String REGEX_WORD_EN = @"[A-Za-z'’]+";

    这个正则表达式可以匹配英文单词,有个缺陷如果只是单个的‘也可以匹配出来,比如 60 ’ 这种,请问如何改正,谢谢

    1 replies    2019-07-10 12:15:08 +08:00
    TonyGong
        1
    TonyGong  
    OP
       Jul 10, 2019
    public static String REGEX_WORD_EN = @"(?!')(?!’)[A-Za-z'’]+";
    暂时测试问题不大
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   973 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:02 · PVG 06:02 · LAX 15:02 · JFK 18:02
    ♥ Do have faith in what you're doing.