From: Mark Thomas Date: 2009-10-13T04:10:08+09:00 Subject: Re: Making one reg ex out of two On Oct 9, 8:46 am, Jim Burgess wrote: > I have a string: > > course_info = > "10.10.09Maths" > > I want to use a reg ex to extract the title from the string, in this > case "Maths" > > So far I came up with: > > course_info.gsub!(/^(.*)/, "") > course_info.gsub!(/<\/title>(.*)$/, "").chomp! > p course_info > # -> "Maths" > > Is it possible amalgamate these two regular expressions into one or to > improve this in any way? This looks like an XML string. Did course_info come from an XML document? An XML parser like Hpricot or Nokogiri would be an improvement.