2015-08-26 39 views
0

我有一個包含除了在這個網址格式文本的一些內容:只保留一個完整的URL

some text http://www.example.com/foo... <http://www.example.com/foo.html> some text 

或格式爲:

some text http://www.example.com/bar <http://www.example.com/bar> some text 

我需要分別進行清潔而成, :

some text http://www.example.com/foo.html some text 

和:

some text http://www.example.com/bar some text 

有沒有辦法用正則表達式來實現這一點?

+1

這可能會幫助:http://www.regular-expressions.info/backref.html –

+1

@AndreaCorbellini謝謝!這有助於(見答案)。 – mossaab

+0

@mossaab我會,如果我不知道評論和答案之間的區別。 – Mena

回答