var a = "[i] earned [c] coin for [b] bonus";
How to get string "__ earned __ coin for __ bonus" from the variable above in JavaScript?
All I want to do is to replace all the bracket []
and its content to __
.
a = a.replace(/\[.*?\]/g, '__');
if you expect newlines to be possible, you can use:
a = a.replace(/\[[^\]]*?\]/g, '__');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With