From: Tim Mcd Date: 2009-01-15T02:47:41+09:00 Subject: Re: Regexp in Ruby Tim Mcd wrote: > Teme Rosi wrote: >> names = ["My name is Jack"] >> if names =~ /My name is (\w+)/i >> puts $1 >> end >> >> >> What im trying to do with this code is to print rest of the line of the >> same line where "My name is" is. But it doesnt work. Can anyone help? > > Hmm, that works for me. I don't know what the /i is for tho. If you need > to tset out regexp's try www.rubular.com Wait a second! Could your problem be this: names is an array. names =~ /yourregexp/ would be trying to match the array. Try names[0] =~ /My name is (\w+)/i Tim. -- Posted via http://www.ruby-forum.com/.