From: John Smith Date: 2010-09-18T00:04:51+09:00 Subject: Re: Printing part what's found with a regex John Smith wrote: > Jonathan Nielsen wrote: >> You will find that portions of the regex marked with parentheses will be >> places in variables called $1, $2, etc. So, you will want to change the >> regex to >> >> /(?!%)\w+\s+(\(\w+\))/ >> >> And then the contents of (\(\w+\)) will be placed in the variable $2. >> >> -Jonathan Nielsen > > hmm I'm trying to print this variable > but I get nothing. I've tried: > > puts "#$2" > puts "#{$2}" Ah just realized it is in variable $1. (?!%) is a look ahead so I guess it doesn't count as a group? -- Posted via http://www.ruby-forum.com/.