Given a string str = "üabc123", and size = 5. I want to get the first 5 bytes("üabc"), and the rest of the string("123").
Currently I'm doing:
str = "üabc123"
size = 5
a = binary_part(str, 0, size) # "üabc"
b = String.trim_leading(str, a) # "123"
Seems like there would be a cleaner way to do this. Is there another way?
You can use binary pattern matching
<< a::binary-size(5), b::binary >> = "üabc123"
a == "üabc"
b == "123"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With