Hi is there away to remove leading zeros from string like this 008,002,004 to bo like this 8,2,4 any help??
Really... Google is your friend: http://stackoverflow.com/questions/6676488/remove-leading-zeros-in-javascript
You can't just blindly pass them as a group, parseInt must be run on each value individually. first=parseInt(002) second = parseInt(003);
How do you have them stored? In an array? // assumes values is an array of numbers with leading zeros for (var t=0; t < values.length; t++) values[t] = parseInt(values[t]); What are you doing with them? How are you passing them? How are they stored? You're really not giving us a lot to work with information-wise. Wait, is this in a string? You'd have to split the string by comma's (assuming it's a common delimiter)...
It's file name and I want to used it without zeros for example file name(003,004) to be like this ( bno 3,4)
This should work: var string = '008,002,0040'; string = string.split(',').map(function(el){ return el.replace(/^0+/g,"");}).join(','); alert(string); Code (markup): http://jsfiddle.net/xQ7vE/
Oddly, on filenames I'd keep the leading zeros, that way you can actually sort them properly since most OS will sort (for example) file11.png before file2.png I've even written code in the past to FORCE filenames to leading zeros... seems strange to want to go the other direction.