Question: 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.

Answer: 
The `$` in RegExp is a special character, so you need to escape it with backslash.

```
new_str = str.replace(new RegExp('\\$', 'g'), '_');

```

however, in JS you can use the simpler syntax

```
new_str = str.replace(/\$/g, '_');

```
........

```
str.replace(new RegExp('\\$', 'g'), '_');

```

Becaue `$` is special char in js, you need to escape it.