From: 7stud -- Date: 2009-10-12T22:48:32+09:00 Subject: Re: Spliting hash using map! Ne Scripter wrote: > Sorry for being unclear. > > Basically, if I say the following > > string = "0002 0003 0004 0005" > > if 0002.match(/#{string}/) > puts string > end > > So I want to say if my string contains the item given in the IF > statement tell me the item that it found, in the example above 0002. > > The code I have above does not match anything. > Your regex is /0002 0003 0004 0005/. That pattern does not appear in the string "0002" (and the integer 0002 does not have a match() method!). Look at this example: string = "0002 0003 0004 0005" if string.match(/0002/) puts string end --output:-- 0002 0003 0004 0005 In this example, the regex is /0002/, and that patter does occur in the string "0002 0003 0004 0005", so there is a match. -- Posted via http://www.ruby-forum.com/.