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?

Community
  • 1
  • 1
Stratus3D
  • 4,648
  • 4
  • 35
  • 67

1 Answers1

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
mbesso
  • 715
  • 4
  • 13