const regex = /(\b)(https?:\/\/)(www.)?[\w-]{2,}\.[a-zA-Z\-0-9]{1,}[\w\/\.\?\=\&\#\-\%\+]*(\b)/ig;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\b)(https?:\\\/\\\/)(www.)?[\\w-]{2,}\\.[a-zA-Z\\-0-9]{1,}[\\w\\\/\\.\\?\\=\\&\\#\\-\\%\\+]*(\\b)', 'ig')
const str = `http://127.0.0.1/openserver/phpmyadmin/sql.php?db=projectx&table=messages&sql_query=SELECT+%2A+FROM+%60messages%60&message_to_show=%D0%97%D0%B0%D0%BF%D0%B8%D1%81%D1%8C+%D0%B1%D1%8B%D0%BB%D0%B0+%D1%83%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B0&goto=tbl_sql.php&token=81b4b5c88dae1706231d6cd2ab925edb&message=%D0%A3%D0%B4%D0%B0%D0%BB%D0%B5%D0%BD%D0%B0+1+%D1%81%D1%82%D1%80%D0%BE%D0%BA%D0%B0.+%28%D0%97%D0%B0%D0%BF%D1%80%D0%BE%D1%81+%D0%B7%D0%B0%D0%BD%D1%8F%D0%BB+0.1904+%D1%81%D0%B5%D0%BA.%29
sd fs `;
const subst = ``;
// 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