From: Robert Klemme Date: 2010-10-20T05:15:13+09:00 Subject: Re: Find block in a long string On 19.10.2010 19:51, Greg Ma wrote: > Gianfranco Bozzetti wrote in post #955473: >> Does this snippet solve your need? >> >> # Given the string: >> str="<p>\n<strong>Location:</strong> Columbus, >> Ohio\n</p>\n\n<" >> # remove unwanted chars with: >> str1=str.gsub(/[&\/;\n]+|lt|gt|strong|p/im,' ').strip.squeeze(' ') >> # and obtain; >> puts "str1: #{str1}" #=> Location: Columbus, Ohio >> # if you wish, remove Location: and obtain; >> str2 = str1.gsub(/Location:\s+/i,'') >> puts "str2: #{str2}" #=> Columbus, Ohio >> >> HTH gfb >> >> "Greg Ma" wrote in message >> news:14b91fa99bddaa2bd5b39c486fd8d1ce@ruby-forum.com... > > Thanks this is what I was looking for :) > I really need to get learning regular expressions... Here's a bit more to play with: http://gist.github.com/635002 Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/