String search in a binary

Carsten Schultz <>
Wed Dec 1 15:18:09 CET 2004


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,

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



Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin
PGP/GPG key on the 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: <>

More information about the erlang-questions mailing list