Replace all spaces in a string with ‘+’ [duplicate] September 17, 2022 by Tarik Here’s an alternative that doesn’t require regex: var str="a b c"; var replaced = str.split(' ').join('+');