Binary String pattern matching

Java House <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAJYUOtfvZgT0F0jL3ncdwzOir4xqQ7ABV-JK9k4uHxw0Jpa49w@mail.gmail.com>
Hello all

I am learning Erlang and have stuck to the following problem.
How to write a function with pattern matching when the parameter is a
binary string.

I have a list of binary strings e.g.
<<3123CHF>>
<<341424343EUR>>
<<14143US>>

I am trying to create a function that matches according to a pattern.

currrency_to_credits({cur, <<A, "CHF">>}, Acc)
  when Value >= <<"1000">>, Value =< <<"10000">> ->
     {chf, Acc + A};
currrency_to_credits({cur, <<A, "EUR">>}, Acc)
  when Value >= <<"1000">>, Value =< <<"10000">> ->
     {eur, Acc + A};
currrency_to_credits({cur, <<A, "US">>}, Acc)
  when Value >= <<"1000">>, Value =< <<"10000">> ->
     {us, Acc + A};

But this does not seem to be the right way.
How can I create a pattern for binary string?
will it work better for list string? How?

Thank you
Nikolas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.