hi i have this variable which looks like this ؛‎ ‎002005 And i want to split it into two halfs three each . What i want to do is to put the first 3 numbers in a new variable and to remove its starting zero padding to get only 2 and the second half also to get just 5
Thank you very much
any help woild be apreciated

Member Avatar
diafol

I'm no expert at js - here's a start. Doubtless, there will be a better way to do it...

var str = '002005';
var bits = str.match(/.{1,3}/g);
alert(parseInt(bits[0]));
alert(parseInt(bits[1]));
Member Avatar
diafol

Can't believe I got a -1 for that! :)

sorry man i meant to upvote you but i doing it from my mobile and i dont know to get it back sorry agai

Member Avatar
diafol

Ha ha, no worries. I seem to get -1 all over the place for pretty harmless posts, thought somebody had a grudge against me. Anyway, glad you got it sorted. :)