Lucky Nl wrote: > Hi > I Need small help that how to remove leading tags > My text is: > str = "<p>Welcome to ruby </p> <p> </p>" > I want result is > str = "<p>Welcome to ruby</p>" > > Can anybody help You mean trailing, rather than leading? You probably want String#gsub or String#gsub!. For example: $ irb --simple-prompt >> str = "<p>Welcome to ruby </p> <p> </p>" => "<p>Welcome to ruby </p> <p> </p>" >> str.gsub!(/( |\s)+/, " ") => "<p>Welcome to ruby </p> <p> </p>" >> Removing empty paragraphs is left as an exercise. For more information on String and Regexp see http://www.ruby-doc.org/docs/ProgrammingRuby/ However for anything other than the most basic transformations, you are almost certainly better off with a HTML parser like Nokogiri, than chomping HTML with regexps. -- Posted via http://www.ruby-forum.com/.