I am trying to filter out all URL from a string input. Currently, I have a regex that is able to find URLs starting with http:// or https:// or ftp:// as seen below:
var _input = document.querySelector("#input");
var btn = document.querySelector("#btn");
var results = document.querySelector("#results");
btn.addEventListener("click", function() {
var input_ = _input.value;
var cleanInput = input_.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '');
results.innerHTML = cleanInput;
});
<textarea id="input" rows="5" style="width: 200px;"></textarea>
<button id="btn">SUBMIT</button>
<div id="results"></div>
What Regex should I use to match www.*** and also it should not case sensitive. http or HTTP should also be match.
.replace(/(?:(?:http|ftp)s?:\/\/|www\.)[\n\S]+/ig, '');