嗨,我有以下代碼,我只想拉出有www的鏈接。在他們只使用正則表達式拉出一個鏈接
<p> Text < href="http://url.com/link/">link text</a> more text < href="http://www.anotehrurl.com/">more link text</a> and < href="http://www.anotherurl.com/sub/sub/link.html">link text</a>. more text < href="http://keepurl.co.uk/link/">link text</a> more text < href="http://www.anotherurl.com/sub/sub/link.html">link text</a>. < href="http://www.anotherurl.com/sub/sub/link.html">link text</a>. < href="http://www.anotehrurl.com/">more link text</a></p>
IM使用reg表達式:
(<a href="http:\/\/www.[\d\D]*?\/">([\d\D]*?)<\/a>)
基本上我想匹配以www開頭的鏈接,而不是匹配任何鏈接是keepurl.co.uk/.... ...
我已經通過rubular把這個與下面出來:
{ 結果1
1. < HREF = 「http://www.anotehrurl.com/」>更多鏈接文本 2.more鏈接文本 結果2
1. < HREF =「HTTP://www.anotherurl。 com/sub/sub/link.html「>鏈接文本。多個文本 < HREF = 「http://keepurl.co.uk/link/」>鏈接文本 2.link文本 結果3
1. < HREF =「http://www.anotherurl.com /sub/sub/link.html「>鏈接文本。鏈接文本。 < HREF =「http://www.anotehrurl.com/」>更多鏈接文本 2.more鏈接文本 }
如u可以看到它拉出比我更想。
歡呼
我如何得到所有的代碼出現在我的previouse問題propperly – fishboy1669 2011-01-26 01:49:10
一定有人做了,因爲所有的HTML和PHP可見 – fishboy1669 2011-01-26 01:49:43