From: "David A. Black" Date: 2005-11-17T21:32:46+09:00 Subject: Re: extracting lines from an address Hi -- On Thu, 17 Nov 2005, Kris Leech wrote: > 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 You probably want a local variable there, rather than a constant. > Street > City > Country" > > --> > > Address_line1 = "12, HouseName" > Address_line2 = "Street" > Address_line3 = "City" > Address_line4 = "Country" This is actually a case where the sometimes odd-seeming way that String#map works (as well as #each and #to_a) can work in your favor: house,street,city,country = address.map {|line| line.strip } David -- David A. Black dblack@wobblini.net