how to detect and get url on string javascript
You input has double ::
after http
. Not sure if it intentional. If it is then use:
var matches = string.match(/\bhttps?::\/\/\S+/gi);
If only one :
is needed then use:
var matches = string.match(/\bhttps?:\/\/\S+/gi);
RegEx Demo
const string = "hei dude, check this link http:://google.com and http:://youtube.com"
const matches = string.match(/\bhttp?::\/\/\S+/gi);
console.log(matches);