For some reason the "".replace()
method only replaces the first occurrence and not the others. Any ideas?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Try this code:
if you don't require the power of RegExp
You have to use the
g
modifier (for global) in your replace call.In your particular case it would be:
Note that you must escape the
/
in the regular expression.