From: ideal one Date: 2011-10-15T03:52:10+09:00 Subject: Ruby functions to split numbers HI All, I have couple of requirements to be handled in ruby, it will be great if anyone can shed some light on this. 1) i have a 8 digit number, to be used in my code as 2 parts(split), like shown below. Number = "34502305" # I put them in double quotes, so that leading zeros are preserved. Var1 = 345 # split firs 3 digits always Var2 = 02305 # split remaining digits with preserving leading Zero if it exists i tried doing something like this, not sure if its correct sprintf("%2d", number) I am not able to preserve leading zero or i get fixnum to string error Cheers -- Posted via http://www.ruby-forum.com/.