How do I remove double or multiple underscores in a string using JavaScript?
E.g.
stack__overflow___website
I will need to eliminate the __ and replace it with a single _.
You can use replace() with a regex to match consecutive underscores:
'stack__overflow___website'.replace(/_+/g, '_')
                        var myString = "stack__overflow___website",
    myFormattedString = myString.split('__').join('_');
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With