javascript - Split string by colon but ignore URL's -
i need split string colons, ignore colons within urls presented in string. example:
var str = 'www.website.com:http://website.com/';
the result should be:
["www.website.com", "http://website.com/"]
it may lot of addresses in row.
i have tried javascript split()
regex (:)(?:[^\/][^\/])
not helping much.
if use negative lookahead can filter out protocols (colons followed double slash) , ports (colons followed digit:
var str = 'www.website.com:http://website.com/:test.com:5000:test.co.uk'; var split = str.split(/:(?!\/\/|\d)/);
Comments
Post a Comment