const regex = /(?:[a-z]{3,9}:\/\/?[\-;:&=\+\$,\w]+?[a-z0-9\.\-]+|[\/a-z0-9]+\.|[\-;:&=\+\$,\w]+@)[a-z0-9\.\-]+(?:(?:\/[\+~%\/\.\w\-_]*)?\??[\-\+=&;%@\.\w_]*#?[\.\!\/\\\w]*)?/gi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?:[a-z]{3,9}:\\\/\\\/?[\\-;:&=\\+\\$,\\w]+?[a-z0-9\\.\\-]+|[\\\/a-z0-9]+\\.|[\\-;:&=\\+\\$,\\w]+@)[a-z0-9\\.\\-]+(?:(?:\\\/[\\+~%\\\/\\.\\w\\-_]*)?\\??[\\-\\+=&;%@\\.\\w_]*#?[\\.\\!\\\/\\\\\\w]*)?', 'gi')
const str = `[PT]Consultório de dentista equipado e pronto //sssss.ssss.sss a funcionar.<br />Com la/boratório, sala de espera, escritório e wc.<br />Alarme instalado. Sistema de som interligado para todas as divisões.<br />Prédio com porteiro.<br />2 minutos (a pé) da estação de metro da Trindade.<br /><br />Fotos 360º:<br /><br />Consultório + Laboratório<br />https://photosynth.net/view.aspx?cid=f0e5b9db-fdec-4e50-9a83-69d7c2bc44e7<br /><br />Escritório<br />https://photosynth.net/view.aspx?cid=da4c64fe-c4cf-45f5-8bf9-ff62d369e98a<br /><br />Sala de espera<br />https://photosynth.net/view.aspx?cid=b631fd55-f7e7-41b3-a9a2-2f687dffeec8[/PT][EN]Consultório + Laboratório<br />http://photosynth.net/view.aspx?cid=f0e5b9db-fdec-4e50-9a83-69d7c2bc44e7[/EN][FR]Consultório + Laboratório<br />www.photosynth.net/view.aspx?cid=f0e5b9db-fdec-4e50-9a83-69d7c2bc44e7[/FR]`;
const subst = `(url)$U`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions