How to remove double or multiple underscores in a string using JavaScript?
eg.
stack__overflow___website
I need to eliminate __and replace it with one _.
__
_
You can use replace()with regex to match consecutive underscores:
replace()
'stack__overflow___website'.replace(/_+/g, '_')
var myString = "stack__overflow___website", myFormattedString = myString.split('__').join('_');
Source: https://habr.com/ru/post/1527690/More articles:Grep error without error message - bashWhy is CountdownTimer not working? - androidHow to transfer bearer token on client side - securityFinishing autocomplete: how to set focus on autocomplete after clicking on a command link - primefacesHTML динамически добавляет входной файл не работает - javascriptTracking online users with Redis - redisHow to lay a detailed model from the controller to the view - c #2 approaches for tracking online users with Redis. Which one is faster? - performanceD3 Dynamic change of Y-axes - d3.jsDoes removeFromParent on SKNode destroy an instance? - iosAll Articles