【问题标题】:php preg_match_all custom patternphp preg_match_all 自定义模式
【发布时间】:2011-08-11 13:39:38
【问题描述】:

我有一个类似的字符串

$string = ">xyz, >abc hi there and also hi to >nrm";

我想查找出现在“>”符号旁边的所有单词 例如在上面的字符串中,它将返回所有单词 xyz、abc 和 nrm

我尝试了一些方法,但没有任何结果

帮帮我,提前谢谢

【问题讨论】:

    标签: php regex preg-match-all


    【解决方案1】:

    您可以执行以下操作:

    preg_match_all("/>(\w+)/", $string, $matches);
    // $matches[1] contains the matches you want.
    

    另请参阅:Example of it in action on Ideone

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多