What does the regular expression /_/g mean?

javascript, regex

Solution

The regex matches the `_` character.

The `g` means Global, and causes the `replace` call to replace all matches, not just the first one.

Problem

JavaScript: ``` .replace(/_/g," "); ``` I have it in my code but can't remember why or what it does! Can one of you regular expression gurus help? I know this may seem basic, but regular expressions are not my cup of tea and googling for `/g` didn't help much.

Original source

Related problems