From: Rob Biedenharn Date: 2008-03-26T03:13:43+09:00 Subject: Re: Clean a header On Mar 25, 2008, at 1:51 PM, Iņaki Baz Castillo wrote: > Hi, I've a string like this: > > header = "Header : \r\n \t \r\n \t 111 aaa 2222 3333 \r\n" > > I need to clean it and leave as follows: > > "Header:111 aaa 2222 3333" > > The best I get is this: > > header.strip.gsub(/(\s*)/,"") > => "Header:111aaa22223333" > > Obviously this is not valid since it "eats" the spaces into the header > body. How could I fix it? > > Thanks in advance. > -- > Iņaki Baz Castillo > irb> header = "Header : \r\n \t \r\n \t 111 aaa 2222 3333 \r\n" => "Header : \r\n \t \r\n \t 111 aaa 2222 3333 \r\n" irb> header.strip.sub(/\s*:\s*/,':').gsub(/\s+/,' ') => "Header:111 aaa 2222 3333" Good enough? -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com