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 __.
Join Stack Overflow to learn, share knowledge, and build your career.
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 |
||||
|
|
if you expect newlines to be possible, you can use:
|
|||||||||||||||||||||
|
|
Here is a fun example of matching groups.
Breakdown
|
|||
|
|
|
|||
|
|