On Mar 25, 2008, at 1:51 PM, I=F1aki Baz Castillo wrote:
> Hi, I've a string like this:
>
> header =3D "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*)/,"")
> =3D> "Header:111aaa22223333"
>
> Obviously this is not valid since it "eats" the spaces into the header
> body. How could I fix it?
>
> Thanks in advance.
> -- =20
> I=F1aki Baz Castillo
> <>
irb> header =3D "Header : \r\n \t \r\n \t 111 aaa 2222 3333 =20=
\r\n"
=3D> "Header : \r\n \t \r\n \t 111 aaa 2222 3333 \r\n"
irb> header.strip.sub(/\s*:\s*/,':').gsub(/\s+/,' ')
=3D> "Header:111 aaa 2222 3333"
Good enough?
-Rob
Rob Biedenharn
http://agileconsultingllc.com