I use the following to remove white space and :. For example ' e-post: ' becomes 'e-post'.
replace(/\s/g,"").replace(/:/g,"");
But I know there is a better way to do it by using only one 'replace'. Could anyone help me please?
Thanks in advance.
I use the following to remove white space and :. For example ' e-post: ' becomes 'e-post'.
replace(/\s/g,"").replace(/:/g,"");
But I know there is a better way to do it by using only one 'replace'. Could anyone help me please?
Thanks in advance.
Simplest way - use alternation:
replace(/\s|:/g,"");
You can probably also use a character class:
replace(/[\s:]/g,"");
How about this?:
replace(/\s|:/g,"");
However, this will only work when you are replacing both regexes with the same string. If you need something different, use your original approach.