开发者

Regular expression matching href=

I've been looking for a few days now, trying to match href links but I need to reduce the results so that the start of the href is:

开发者_运维问答
<a href="/hp/

Does anyone know a regular expression that could do this?


preg_match('/<a href=["\']?(\/load\/[^"\'\s>]+)["\'\s>]?/i', $string);

This matches:

<a href="/load/anytext">

and returns its href value, but not

<a href="http://www.example.com">

Pay attention: if you want the regex to match also href="/load/" without other text then you have to substitute the + before the ? with a *, else this regex matches only href="/load/anytext..."

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜