From: botp Date: 2007-12-04T11:39:01+09:00 Subject: Re: Ruby regexp Match On 12/4/07, John Sheahan wrote: > I want to be able to do a kind of match like: > m/^Title([a-zA-Z0-9])//g > and access what's inside the () with x[0]. ruby gives more (objects), see http://ruby-doc.org/core/classes/MatchData.html some simple examples t="Title123asdf" #=> "Title123asdf" /^Title([a-zA-Z0-9])/.match(t) #=> # /^Title([a-zA-Z0-9])/.match(t)[0] #=> "Title1" /^Title([a-zA-Z0-9])/.match(t)[1] #=> "1" $~ #=> # $~[0] #=> "Title1" $~[1] #=> "1" x=/^Title([a-zA-Z0-9])/.match(t) #=> # x[0] #=> "Title1" x[1] kind regards -botp