0

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

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by diafol
1

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]));
0

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

Edited by shandoosheri

0

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. :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.