Clean a header

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

SGksIEkndmUgYSBzdHJpbmcgbGlrZSB0aGlzOgoKIGhlYWRlciAgPSAgIkhlYWRlciAgICA6IFxy
XG4gXHQgIFxyXG4gIFx0IDExMSBhYWEgMjIyMiAzMzMzICAgICAgXHJcbiIKCkkgbmVlZCB0byBj
bGVhbiBpdCBhbmQgbGVhdmUgYXMgZm9sbG93czoKCiAgIkhlYWRlcjoxMTEgYWFhIDIyMjIgMzMz
MyIKClRoZSBiZXN0IEkgZ2V0IGlzIHRoaXM6CgogIGhlYWRlci5zdHJpcC5nc3ViKC8oXHMqKS8s
IiIpCiAgPT4gIkhlYWRlcjoxMTFhYWEyMjIyMzMzMyIKCk9idmlvdXNseSB0aGlzIGlzIG5vdCB2
YWxpZCBzaW5jZSBpdCAiZWF0cyIgdGhlIHNwYWNlcyBpbnRvIHRoZSBoZWFkZXIKYm9keS4gSG93
IGNvdWxkIEkgZml4IGl0PwoKVGhhbmtzIGluIGFkdmFuY2UuCgoKCi0tIApJw7Fha2kgQmF6IENh
c3RpbGxvCjxpYmNAYWxpYXgubmV0Pgo=
 
R

Rob Biedenharn

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
<[email protected]>


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
(e-mail address removed)
 
I

Iñaki Baz Castillo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,285
Messages
2,571,416
Members
48,111
Latest member
PorterZ31

Latest Threads

Top