How can I replace all occurrences of a dollar ($) with an underscore (_) in javascript?
Posted
by Ryan Tomlinson
on Stack Overflow
See other posts from Stack Overflow
or by Ryan Tomlinson
Published on 2010-03-12T17:05:54Z
Indexed on
2010/03/12
17:07 UTC
Read the original article
Hit count: 124
JavaScript
|replace
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore.
I have tried:
str.replace(new RegExp('$', 'g'), '_');
But this doesn't work for me and nothing gets replaced.
© Stack Overflow or respective owner