JSFiddle - React, Tailwind, and code Playground
HTML
<input id="input" type="text" value="https://htmlforum.io/topic/63758-zamena-teksta-na-html-css-js/">
<br>
<button id="button">Update URL</button>
<br>
<div id="result"></div>
JavaScript
document.getElementById("button").addEventListener("click", function() {
var input = document.getElementById('input');
var result = document.getElementById('result');
var url = input.value;
var index = url.search(/[\/\/]\w*.(\/)/gm);
var newDomain = "https://html.com";
var newUrl = newDomain + url.substr(index);
result.innerText = newUrl;
});