From: Robert Klemme Date: 2011-09-20T16:59:34+09:00 Subject: Re: array.map! + delete_if possible ? On Mon, Sep 19, 2011 at 5:24 PM, Kassym Dorsel wrote: > Thanks for the answer. Here is the initial array. > > arr[0]=1201 0 "userid" 1202 0 "lname" 1203 0 "mname" 1204 0 "lname" 1217 > 0 "password" > arr[1]= > arr[2]=4 0 emailaddress > arr[3]=1201 0 "userid" 1202 0 "lname" 1203 0 "mname" 1204 0 "lname" 1217 > 0 "password" > arr[4]= > arr[5]=1201 0 "userid" 1202 0 "lname" 1203 0 "mname" 1204 0 "lname" 1217 > 0 "password" > > The email address line is random depending if the user inputed one or > not and may or may not show up. > > I want to end up with this : > > arr[0]=userid::lname::mname::lname::password::emailaddress > etc https://gist.github.com/1228601 > In the end I iterate over this array and input the info data into a > database. I don't think I can combine both loops because I need to check > index for the email and if found go back to index-1 for the rest of the > info and then input into database. I picked the approach to identify fields by their number and create records based on that. > Also instead of using arr.delete("") could I not use > arr.delete(/[^14}*/), but does not seem to work. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/