求 匹配多個a標籤串連和名字 Regex解決方案

來源:互聯網
上載者:User
求 匹配多個a標籤串連和名字 Regex
比如這樣的源碼

HTML code
知識 維普資訊 中國期刊網 龍源期刊網 郵政報刊訂閱網 雜誌鋪 MBA智庫百科 星空天文網 勸學網
 牧夫天文論壇 專利之家 環球科學 科學松鼠會 UFO探索網 果殼網 我學網 網易公開課
 維基百科 我要自學網 中國留學網 知乎 網易學院 搜搜問問 新手學上網 國家核安全域
 word聯盟 愛問知識人 中國文明網


唉 說來都不好意思,

前不久問了這個問題 ,但是當時是只有一個a標籤時,有很多好心人幫我解決了。http://topic.csdn.net/u/20111216/16/934599d3-8e99-4b94-8dae-28e5b9c455c4.html
但是,現在是多個A標籤時,我怎麼改都是出錯。
還請高手指點一下。我應該怎麼弄一下。



------解決方案--------------------
PHP code
preg_match_all('/(.*)$href) {    $arr[$matches[2][$k]] = $href;}var_export($arr);/**輸出結果:array ( '維普資訊' => 'http://www.cqvip.com/', '中國期刊網' => 'http://www.chinaqking.com/', '龍源期刊網' => 'http://www.qikan.com.cn/', '郵政報刊訂閱網' => 'http://bk.183.com.cn/index.do', '雜誌鋪' => 'http://www.zazhipu.com/', 'MBA智庫百科' => 'http://wiki.mbalib.com/', '星空天文網' => 'http://www.cosmoscape.com/', '勸學網' => 'http://www.quanxue.cn/', '牧夫天文論壇' => 'http://www.astronomy.com.cn/bbs/', '專利之家' => 'http://www.patent-cn.com/', '環球科學' => 'http://www.sciam.com.cn/', '科學松鼠會' => 'http://songshuhui.net/', 'UFO探索網' => 'http://www.ufo-1.cn/', '果殼網' => 'http://www.guokr.com/', '我學網' => 'http://www.5xue.com/', '網易公開課' => 'http://v.163.com/open/', '維基百科' => 'http://zh.wikipedia.org/', '我要自學網' => 'http://www.51zxw.net/', '中國留學網' => 'http://www.cscse.edu.cn/', '知乎' => 'http://www.zhihu.com/', '網易學院' => 'http://tech.163.com/school/video/', '搜搜問問' => 'http://wenwen.soso.com/', '新手學上網' => 'http://xue.baidu.com/', '國家核安全域' => 'http://nnsa.mep.gov.cn/', 'word聯盟' => 'http://www.wordlm.com/', '愛問知識人' => 'http://iask.sina.com.cn/', '中國文明網' => 'http://www.wenming.cn/', )//PS:一次達到,好像沒啥方法。*/
------解決方案--------------------
PHP code
知識 維普資訊 中國期刊網 龍源期刊網 郵政報刊訂閱網 雜誌鋪 MBA智庫百科 星空天文網 勸學網
 牧夫天文論壇 專利之家 環球科學 科學松鼠會 UFO探索網 果殼網 我學網 網易公開課
 維基百科 我要自學網 中國留學網 知乎 網易學院 搜搜問問 新手學上網 國家核安全域
 word聯盟 愛問知識人 中國文明網 ';$patten = '/(.*)<\/a>/iU';preg_match_all($patten,$str,$match);$result = array();for($i = 0;$i";print_r($result);?>
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.