4

I came across questions on how to find a value in a list and I am also aware of lists:member/2.

Is there something like lists:member/2 binary strings? I need to check if a value is present in the binary. I imagine something like this:

value_in_binary(<<"Some random data">>, <<"d">>). 
%> true

Does anything like this exist? If not, how would I go about implementing a function like this?

1 Answer 1

8

Check out binary:match/2,3. For example

1> binary:match(<<"some random data">>, <<"d">>).
{8,1}
2> binary:match(<<"some random data">>, <<"z">>).
nomatch
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.