douxiangdiao6348 2010-03-05 12:20
浏览 19

php正则表达式从链接中的rel属性中删除文本

is there a really easy way to grab the text of a rel attribute i.e

<a href='#' rel='i want this text here'></a>.

I have tried this morning with regex but am having no luck.

  • 写回答

5条回答 默认 最新

  • dtnqbre7980007 2010-03-05 12:24
    关注

    This should work:

    preg_match_all('%<a[^>]+rel=("([^"]+)"|\'([^\']+)\')[^>]*>%i', $html, $matches);
    print_r($matches);
    
    评论

报告相同问题?