Please help me cause I'm noob in programming. What should I do to make it replace all string matches? If I write /http://example.com/ad//g instead of "http://example.com/ad/" it won't run properly either.
<!DOCTYPE html>
<html>
<body>
<h3>Instert your links</h3>
input:<br>
<textarea id="myTextarea">
http://example.com/ad/123.html
http://example.com/ad/345.html
http://example.com/ad/3567.html
</textarea>
<button type="button" onclick="myFunction()">Get clean links</button>
<p id="links"></p>
<script>
function myFunction() {
var x = document.getElementById("myTextarea").value;
var x = x.replace("http://example.com/ad/", "http://example.com/story/");
var x = x.replace("\n","</br>");
document.getElementById("links").innerHTML = x;
}
</script>
</body>
</html>