avarus avarus -3 years ago 73
Javascript Question

Replace javascript special characters appearing in particular order

I am looking to turn a string like




that is replacing all the special characters (but not the double quotes and comma in the outermost square brackets) with empty spaces.

I have tried this combination
.replace(/[^0-9\.,]/g, "")
without success. Thanks for your help !

Answer Source

You could use a regex that try both cases you want to substitute:


See the live example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download