From: Phil Meier Date: 2007-07-26T16:29:59+09:00 Subject: Re: A method to search and cut in Ruby. scomboni@gmail.com schrieb: > On Jul 25, 7:05 pm, Phrogz wrote: >> On Jul 25, 4:59 pm, scomb...@gmail.com wrote: ... >> ...or did you want the leading whitespace chomped? >> >> irb(main):004:0> s.split( /\s*:\s*/ ) >> => ["Foo", "Bar"] >> irb(main):005:0> s.split( /\s*:\s*/ ).last >> => "Bar" > > I was looking at this method as well. I was having trouble though as I > know the left hand side column so for this example the Compression > portion then the colon : the remainder could be anything for instance > a description with lots of text and could also contain a additional > colon. At the shell prompt I could grep "Compression" | cut -d: -f2- > and that would grab everything... To get everything after the first colon you can use: s =~ /^.*?:/ textAfterColon = $'.dup To also get rid of the spaces directly after the first colon use this Regex: s =~ /^.*?:\s*/ textAfterColon = $'.dup The trick is to anchor the regex (i.e. using ^) BR Phil