Mohan Ram Mohan Ram - 1 year ago 107
Javascript Question

How to replace substring in Javascript?

To replace substring.But not working for me...

var str='------check';


Output: -----check

Jquery removes first '-' from my text. I need to remove all hypens from my text. My expected output is 'check'

Answer Source


str = str.replace(/-/g, ""); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download