From: Robert Klemme Date: 2012-09-03T14:36:08+09:00 Subject: Re: How to get part of a string On Sun, Sep 2, 2012 at 11:30 PM, Ryan Davis wrote: > > On Sep 2, 2012, at 14:23 , Fosiul Alam wrote: > >> irb(main):001:0> line ='/dev/cciss/c0d11p1 /xxx/xxxxx/BD55-11 >> ext3 defaults,noatime,nodiratime 1 0' >> => "/dev/cciss/c0d11p1 /xxx/xxxx/BD55-11 ext3 >> defaults,noatime,nodiratime 1 0" >> irb(main):002:0> line[%r{US\d+(?=-\d$)}] >> => nil > > That is working perfectly. There is no "US" anywhere in your string. Also the line has a completely different structure from what was presented in the first posting of this thread. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/