From: botp Date: 2011-07-28T15:21:59+09:00 Subject: Re: siimple string manuplation logic. But i did not getting correct one On Thu, Jul 28, 2011 at 1:57 PM, kotin 76 wrote: > string1 = "/dev/sdb  1949612  102404   1847208   6% /media/4B22-5451" > if m2=string1.match( %r{/media/\w+} ).to_s then careful here. the condition returns a string, ergo, it will always return true. also \w does not include the dash char > if m2 =~ %r{/media/} then you may not need this additional if > puts "pass" > puts "mediastring = #{m2}" > end > end try eg, string1 = "/dev/sdb 1949612 102404 1847208 6% /media/4B22-5451" if m2=string1.match( %r{/media/.+} ) puts "mediastring=#{m2}" end output: mediastring=/media/4B22-5451 there are simpler ways to solve your objective, but we think you will get there. happy rubying and best regards, -botp