javascript - Regex replace a set of characters -
i want replace + - ( ) , space empty character in javascript string. expression i'm using is:
"+1 - (042) - 123456".replace(/[\+\-\' '\(\)]/, ""); which results in:
"1 - (042) - 123456" only + replaced , not other characters. error in expression?
when use square brackets list characters remove/change or whatever, don't want escape them. , recommend using \s instead of , and, of course, need global flag - g.
"+1 - (042) - 123456".replace(/[+()\s-]/g, "")
Comments
Post a Comment