String search in a binary

Carsten Schultz carsten@REDACTED
Wed Dec 1 15:18:09 CET 2004


Hi!

I have the following piece of code:

extract_contents(Bin) when binary(Bin) ->
    Str = binary_to_list(Bin),
    Start = string:str(Str, "<a name=\"datei")-1,
    End = string:rstr(Str, "</body>"),
    Len = End-Start-1,
    <<_:Start/binary, C:Len/binary, _/binary>> = Bin,
    C.

The binary_to_list is bothering me.  Is there a short and efficient
version doing the same?

Thanks,

Carsten

-- 
Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers, 
fingerprint on my home page.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20041201/0783661d/attachment.bin>


More information about the erlang-questions mailing list