From: Greg Ma Date: 2010-10-20T02:51:29+09:00 Subject: Re: Find block in a long string 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... -- Posted via http://www.ruby-forum.com/.