Erlang binary pattern matching fails -
why issue badmatch error? can't figure out why fail:
<<ipaddr, ":*:*">> = <<"2a01:e34:ee8b:c080:a542:ffaf:*:*">>.
pattern matching of binary proceeds left-to-right match ipaddr first before tries following segment. there no back-tracking until there match. default typed variable ipaddr matches 1 byte. see bit syntax expressions , bit syntax proper description , more examples.
as alternative using pattern matching here might consider using binary module. there 2 functions useful you: binary:match/2/3 , binary:split/2/3. these search may better fit problem.
as last alternative try using regular expressions , re module.
Comments
Post a Comment