I have a few strings for example
-11 -11 --11
-22 ----22 -22
I need to replace any count of -
coming one by one to single -
.
After replacing i should get
-11 -11 -11
-22 -22 -22
Thanks!
I have a few strings for example
-11 -11 --11
-22 ----22 -22
I need to replace any count of -
coming one by one to single -
.
After replacing i should get
-11 -11 -11
-22 -22 -22
Thanks!
Just use replace on string with regex that matches more than one number of occurences of '-' with a single '-'
my_str = my_str.replace(/-{2,}/g, '-')