Reputation: 480
I need to replace '+' and ' ' (space) signs in my string with ''; Have RegExp for spaces > /\s/g, need to add '+' symbol to this. Any help? Thanks.
Upvotes: 1
Views: 1686
Reputation: 4614
If you specifically want to replace spaces, you can just use a literal space in your regex pattern. \s
is a character class that matches all whitespace characters (newline, carriage return, tab, etc).
To match both spaces and plus signs, you can create a character set with square brackets:
/[ +]/g
Demo: https://regex101.com/r/Lx2U2G/1
Upvotes: 2