I would like to know how I can do to remove the link from a string in javascript.
str = "hey olha isso http://google.com.br, legal né?"
var test = str.description.replace(/.*?:///g, "");
Expected result:
Hey look at this, cool huh?
I would like to know how I can do to remove the link from a string in javascript.
str = "hey olha isso http://google.com.br, legal né?"
var test = str.description.replace(/.*?:///g, "");
Expected result:
Hey look at this, cool huh?
You can use this regular expression.
var urlPattern = /(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/g;
var textoComUrl = "hey olha isso http://google.com.br/, legal né?";
var textoSemUrl = textoComUrl.replace(urlPattern, "");
console.log(textoSemUrl);
var test = test.description.replace(/.*?:\/\//g, "");