From: w_a_x_man Date: 2010-12-15T05:05:21+09:00 Subject: Re: Need Help with Split On Dec 14, 1:05 pm, "A. Mcbomb" wrote: > I have a list of records that need to be split between the address and > the city. Here is some of the data: > > -16 Bonner StreetHartford,-CT > -450 Main StreetHartford,-CT > -812 Farmington AvenueWest Hartford,-CT > -25 Forest Street No. 18Stamford,-CT > -25 Forest Street No. 6AStamford,-CT > -1450 Main StreetBridgeport,-CT > > If you notice, the address butts directly up against the city name and > the only thing that is consistant it that the city always starts with a > capital letter (but can be more than one word). > > If I could find a way to split where a lower case letter butts directly > against an Upper case letter, that might be a good start. > > example: StreetHartford => if I could split between the lower case t and > the upper case H that are directly next to each other? > > thanks > > atomic > > -- > Posted viahttp://www.ruby-forum.com/. DATA.each{|s| city = s.reverse[ /^.*?,.*?[[:upper:]](?=[\d[:alpha:]])/m ].reverse street = s[0, s.size - city.size] puts street puts city } __END__ -16 Bonner StreetHartford,-CT -450 Main StreetHartford,-CT -812 Farmington AvenueWest Hartford,-CT -25 Forest Street No. 18Stamford,-CT -25 Forest Street No. 6AStamford,-CT -1450 Main StreetBridgeport,-CT