How can I globally replace the | (pipe) symbol in a string? When I try to replace it with \"so|me|str|ing\".replace(/|/g, \'-\'), I get \"-s-
|
\"so|me|str|ing\".replace(/|/g, \'-\')
\"-s-
| means OR, so you have to escape it like this: \|
OR
\|