I have a few strings like so:
str1 = "00001011100000"; // 10111
str2 = "00011101000000"; // 11101
...
I would like to strip the leading AND closing zeros from every string using regex with ONE operation.
So far I used two different functions but I would like to combine them together:
str.replace(/^0+/,'').replace(/0+$/,'');
See Question&Answers more detail:os