sql server - TSQL - Grab valid URLs -
i have table looking this:
url ============== www.google.com http://www.yahoo.com/ www.192.168.1.1.com 192.168.1.5 www.192.168.5.149/service.ir test.sitename.com
so question seperats 2 sections:
- getting urls based on pattern (
(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
). - formatting urls aren't valid (based on pattern)
so came query part one:
select url userwebsites url '%(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?%'
but have no idea how format urls.
is there more elegant way this?
t-sql isn't tool doing string parsing--you're far better off writing clr function , doing work there. there tons of things can regex in simple function--and more efficient code (because writing resembling regex functionality t-sql string operators going long , involved).
Comments
Post a Comment