Why does this issue a badmatch error? I can’t figure out why this would fail:
<<IpAddr, ":*:*">> = <<"2a01:e34:ee8b:c080:a542:ffaf:*:*">>.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Pattern matching of a binary proceeds left-to-right so it will match
IpAddrfirst before it tries the following segment. There is no back-tracking until there is a match. A default typed variable likeIpAddrmatches one byte. See Bit Syntax Expressions and Bit Syntax for a proper description and more examples.As alternative to using pattern matching here you might consider using the
binarymodule. There are two functions which could be useful to you:binary:match/2/3andbinary:split/2/3. These search which may better fit your problem.As a last alternative you could try using regular expressions and the
remodule.