我想要VB.NET的正則表達式來刪除字符串中的所有超鏈接,包括協議https和http,完整文檔名稱,子域名,查詢字符串參數,因此所有鏈接都是這樣的:用VB.NET替換字符串中的所有超鏈接
- http://www.example.com
- http://www.example.com/
- https://www.example.com
- http://www.example.com/page.html?t=7
- http://example.com?q=test&sort=1
- www.example.com
- 等
下面是我在所有環節需要拆除工作的字符串:
Dim description As String
description = "Deep purples blanket/wrap. It is gorgeous" & _
"in newborn photography. " & _
"layer" & _
"beneath the baby.....the possibilities are endless!" & _
"You will get this prop! " & _
"Gorgeous images using Lavender as a basket filler " & _
"Photo by Benbrook, TX" & _
"Imaging, Ontario" & _
"http://www.photo.com?t=3" & _
" www.photo.com" & _
" http://photo.com" & _
" https://photo.com" & _
" http://www.photo.nl?t=1&url=5" & _
"Photography Cameron, NC" & _
"Thank you so much ladies!!" & _
"The flower halos has beautiful items!" & _
"http://www.enchanting.etsy.com" & _
"LIKE me on FACEBOOK for coupon codes, and to see my full product line!" & _
"http://www.facebook.com/byme"
我現在擁有的一切:
description = Regex.Replace(description, _
"((http|https|ftp)\://[a-zA-Z0-9\-\.]+(\.[a-zA-Z]{2,3})?(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*)", "")
它取代了大多數的鏈接,但沒有協議的鏈接,如www.example.com
我如何改變我的表達以包含這些鏈接?
Downvote的原因:擁有超過1,600的聲望,你應該知道[問]。提示:顯示你到目前爲止所嘗試過的。 –