[Solved] How to use regular expression replacement string [closed]


var str="@username(123) test@username2(234) test"
document.write(str.replace(/@(\w+?)\((\d+?)\)/g, '<a href="https://stackoverflow.com/questions/16208629/localhost/home/userid=">$1</a>'));
// Result: <a href="https://stackoverflow.com/questions/16208629/localhost/home/userid=123">username</a> test<a href="localhost/home/userid=234">username2</a> test

solved How to use regular expression replacement string [closed]