开发者

preg_match matching multiple matches

I'm trying to use preg_match to extract info from

href="domai开发者_开发技巧n.com/subdir/?key=value

The info I want are

  1. domain.com
  2. subdir
  3. key
  4. value

Can someone suggest what is the correct way to write the preg_match statement?

Thanks!


use this as your regex

/href="(.+..+?)/(.+?)/(\?.+?=.+)"/

that should work

preg_match('/href="(.+\..+?)\/(.+?)\/(\?.+?=.+)"/', $input, $matches);
echo "First Match: {$matches[0]}\n";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜