2008/3/25, Iñaki Baz Castillo <ibc / aliax.net>:

>  -------
>  Content-Length:
>  1234: blablabla
>  -------
>
>  In that case the code above returns 1234 while it should return 0.
>
>  Demostration:
>
>
>  "Via: via1,via2,\r\n via3\r\nFrom: from_user@domain\nContent-length:
>
> \r\n1234: blabla\nTo: to_user@domain\n"[/content-length\s*:\s*(\d+)/i,
>  1].to_i
>  => 1234
>
>
>  I'm trying to solve it by ading [^(\r|\n)] after (\d+) but I get
>  nothing. Please, could you help me with this?


I think I have now the solution. The problem is that \s matches also
\n so what I do now is:


[/content-length\s*:[ \t]*(\d+)/i, 1].to_i

(I allow any space or tab before the expected numbers but no \r or \n).



-- 
Iñaki Baz Castillo
<ibc / aliax.net>