From: luke (dot) Date: 2005-11-17T20:32:18+09:00 Subject: Re: extracting lines from an address there might be a cleaner way of doing it, but this will work: # assign database entry to a variable address = "12, HouseName Street City Country" # make an array from the string, dividing each line by line breaks lines = address.split("\n") # each line is an element in the array, strip takes whitespace out address_line1 = lines[0].strip address_line2 = lines[1].strip address_line3 = lines[2].strip address_line4 = lines[3].strip "Kris Leech" wrote in message news:80905211372dc9672c5c6dfa4b617c9a@ruby-forum.com... > I have an address stored in mysql as a text field. > I'm using ActiveRecord to access the field. > But how do I get each line of the address in to their own strings? > > eg. > > Address = "12, HouseName > Street > City > Country" > > --> > > Address_line1 = "12, HouseName" > Address_line2 = "Street" > Address_line3 = "City" > Address_line4 = "Country" > > > Many thanks, K. > > > > -- > Posted via http://www.ruby-forum.com/. > >