[erlang-questions] Erlang regex

Matteo mcanato@REDACTED
Wed May 21 21:57:36 CEST 2008


Hi Pablo,
thanks for the quick reply!
You have understand exactly my problem: i'm reading the data from a custom
network protocol.

So i will use the binaries.
Thanks again,
M.Canato



On Wed, May 21, 2008 at 9:48 PM, Pablo Polvorin <pablo.polvorin@REDACTED>
wrote:

> Hello,
> instead of regular expression, I would suggest to use pattern matching
> instead:
> 1> A = <<"OK 01 xxxxxxxx\r\n">>.
> <<"OK 01 xxxxxxxx\r\n">>
> 2> <<"OK 01",X/binary>> = A.
> <<"OK 01 xxxxxxxx\r\n">>
> 3> X.
> <<" xxxxxxxx\r\n">>
>
> besides that, if what you are parsing is some sort of network
> protocol, you won't want to represent strings as lists(), but use
> binaries like in the previous example.
>
>
> 2008/5/21, Matteo <mcanato@REDACTED>:
> > Hi to all,
> > i'm a noob of erlang programming. I would like to have some infos about
> > extracting a substring from a string....
> > Or better, my situation is this:
> >
> > i have a string:
> > str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont know
> > and every time change...
> >
> > and i need to extract the "xxxxxxx" into another string (str2 for
> exaple).
> >
> > Sorry for my english.
> >
> > Best regards
> > M.Canato
> >
>
>
> --
> --
> pablo
> http://ppolv.wordpress.com
> ----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080521/b9c9d3ff/attachment.htm>


More information about the erlang-questions mailing list