I'm trying to create a regex to replace zeros in list with an empty value but not replace the zeros in ten, twenty, thirty, etc.
list = 0,1,0,20,0,0,1,,1,3,10,30,0
desired list = ,1,,20,,,1,,1,3,10,30,
Using this in the javascript replace function
Any help/tips appreciated!
Should be very simple using word boundaries, \b0\b
:
s = s.replace(/\b0\b/g, '');
Working example: http://jsbin.com/ipuru4
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