How to globally replace pipe symbol "|" in string
Try using "so|me|str|ing".replace(/[|]/g, '-')
This is a great resource for working with RegEx: https://www.regex101.com/
|
has special meaning (A|B
means "match A or B"), so you need to escape it:
"so|me|str|ing".replace(/\|/g, '-');
|
means OR
, so you have to escape it like this: \|