fuhanfeng
V2EX  ›  问与答

匹配中文、英文和空格,但首位不允许空格,不能连续使用空格的正则

  •  
  •   fuhanfeng · Jun 1, 2015 · 3642 views
    This topic created in 4178 days ago, the information mentioned may be changed or developed.
    对写正则比较弱,希望大家帮忙写一个适用于PHP的正则,谢谢!
    3 replies  •  2015-06-01 17:33:35 +08:00
    imn1
    imn1
    Jun 1, 2015❤️1
    1
    ^[A-Za-z\u4e00-\u9fcf](?:(?! )[A-Za-z \u4e00-\u9fcf]])+$
    没环境测试
    minuux
    minuux
    Jun 1, 2015
    2
    preg_match('/^[^\d\W][\w]+$/iu', $str) ? TRUE : FALSE;
    minuux
    minuux
    Jun 1, 2015
    3
    看错了,原来要可以使用空格...可以在那基础上稍微改下
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1648 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:15 · PVG 22:15 · LAX 06:15 · JFK 09:15
    ♥ Do have faith in what you're doing.