Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Clean a header

Reply
Thread Tools

Clean a header

 
 
Iñaki Baz Castillo
Guest
Posts: n/a
 
      03-25-2008
SGksIEkndmUgYSBzdHJpbmcgbGlrZSB0aGlzOgoKIGhlYWRlci AgPSAgIkhlYWRlciAgICA6IFxy
XG4gXHQgIFxyXG4gIFx0IDExMSBhYWEgMjIyMiAzMzMzICAgIC AgXHJcbiIKCkkgbmVlZCB0byBj
bGVhbiBpdCBhbmQgbGVhdmUgYXMgZm9sbG93czoKCiAgIkhlYW RlcjoxMTEgYWFhIDIyMjIgMzMz
MyIKClRoZSBiZXN0IEkgZ2V0IGlzIHRoaXM6CgogIGhlYWRlci 5zdHJpcC5nc3ViKC8oXHMqKS8s
IiIpCiAgPT4gIkhlYWRlcjoxMTFhYWEyMjIyMzMzMyIKCk9idm lvdXNseSB0aGlzIGlzIG5vdCB2
YWxpZCBzaW5jZSBpdCAiZWF0cyIgdGhlIHNwYWNlcyBpbnRvIH RoZSBoZWFkZXIKYm9keS4gSG93
IGNvdWxkIEkgZml4IGl0PwoKVGhhbmtzIGluIGFkdmFuY2UuCg oKCi0tIApJw7Fha2kgQmF6IENh
c3RpbGxvCjxpYmNAYWxpYXgubmV0Pgo=

 
Reply With Quote
 
 
 
 
Rob Biedenharn
Guest
Posts: n/a
 
      03-25-2008
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




 
Reply With Quote
 
 
 
 
Iñaki Baz Castillo
Guest
Posts: n/a
 
      03-25-2008
El Martes, 25 de Marzo de 2008, Rob Biedenharn escribi=F3:

> irb> header =3D "Header : \r\n \t \r\n \t 111 aaa 2222 3333
> \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?


No good, it's fantastic

Thanks a lot.


=2D-=20
I=F1aki Baz Castillo

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header files with "header.h" or <header.h> ?? mlt C++ 2 01-31-2009 02:54 PM
Visual C++'s :"clean solution" doesn't clean the solution? plenty900@yahoo.com C++ 8 05-31-2008 04:57 PM
How do I clean a virus within an inbox or just clean only that infectedattachment or LOCATE AND delete just that attachment ? Vinayak Firefox 1 08-14-2006 06:19 PM
Clean up my Hard drive before selling it. Clean Registry? what else? baaab Computer Support 5 05-10-2005 08:30 AM
how to avoid using another header file inside a header file? Newsgroup - Ann C++ 4 11-02-2003 01:20 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57