Mohan Ram Mohan Ram - 10 months ago 86
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, "");