| Paste number 69680: | split binary by converting to list |
| Pasted by: | mmagin |
| When: | 1 year, 9 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1HRK |
| Channel: | None |
| Paste contents: |
split_binary_on_as_string(Bin, Match) ->
Str = binary_to_list(Bin),
Offset = string:chr(Str, Match),
{list_to_binary([string:substr(Str, 1, Offset-1)]),
list_to_binary([string:substr(Str, Offset+1)])}.Annotations for this paste:
| Annotation number 1: | less dumb version |
| Pasted by: | mmagin |
| When: | 1 year, 9 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1HRK/1 |
| Paste contents: |
split_binary_match(Bin, Match) ->
Str = binary_to_list(Bin),
Offset = string:chr(Str, Match),
{Some, <<_Char, Rest/binary>>} = split_binary(Bin, Offset-1),
{Some, Rest}.