php抓取文章內容分析

來源:互聯網
上載者:User

標籤:style   blog   http   color   ar   div   htm   amp   

preg_match_all — 執行一個全域Regex匹配

int preg_match_all ( string pattern, string subject, array matches [, int flags] )在 subject 中搜尋所有與 pattern 給出的Regex匹配的內容並將結果以 flags 指定的順序放到 matches 中。搜尋到第一個匹配項之後,接下來的搜尋從上一個匹配項末尾開始。flags 可以是下列標記的組合(注意把 PREG_PATTERN_ORDER 和 PREG_SET_ORDER 合起來用沒有意義):PREG_PATTERN_ORDER對結果排序使 $matches[0] 為全部模式比對的數組,$matches[1] 為第一個括弧中的子模式所匹配的字串組成的數組,以此類推。
<?php    preg_match_all ("|<[^>]+>(.*)</[^>]+>|U","<b>example: </b><div align=left>this is a test</div>",    $out, PREG_PATTERN_ORDER);    print $out[0][0].", ".$out[0][1]."\n";    print $out[1][0].", ".$out[1][1]."\n";?>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.