airyland
V2EX  ›  问与答

求教正则表达式。

  •  
  •   airyland · Aug 23, 2011 · 4790 views
    This topic created in 5556 days ago, the information mentioned may be changed or developed.
    正则获取里@后面的用户名,用下面的php代码只能获取第一个用户名,如何获取所有的呢?

    $par = "/@(.*?)\s+/is";
    preg_match($par, $string,$arr);
    2 replies  •  1970-01-01 08:00:00 +08:00
    wctbok
    wctbok
    Aug 23, 2011
    1
    全局匹配要用 preg_match_all 函数,手册上有详细说明。
    airyland
    airyland
    OP
    Aug 23, 2011
    2
    @wctbok 是的,刚刚才翻到,囧。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1494 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 14:54 · PVG 22:54 · LAX 06:54 · JFK 09:54
    ♥ Do have faith in what you're doing.