V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
airyland
V2EX  ›  问与答

求教正则表达式。

  •  
  •   airyland · 2011-08-23 16:01:03 +08:00 · 3928 次点击
    这是一个创建于 4657 天前的主题,其中的信息可能已经有所发展或是发生改变。
    正则获取里@后面的用户名,用下面的php代码只能获取第一个用户名,如何获取所有的呢?

    $par = "/@(.*?)\s+/is";
    preg_match($par, $string,$arr);
    2 条回复    1970-01-01 08:00:00 +08:00
    wctbok
        1
    wctbok  
       2011-08-23 16:23:18 +08:00
    全局匹配要用 preg_match_all 函数,手册上有详细说明。
    airyland
        2
    airyland  
    OP
       2011-08-23 16:28:16 +08:00
    @wctbok 是的,刚刚才翻到,囧。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5105 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:06 · PVG 17:06 · LAX 02:06 · JFK 05:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.