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

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -