[erlang-questions] Erlang regex

Pablo Polvorin pablo.polvorin@REDACTED
Wed May 21 21:48:52 CEST 2008


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
----



More information about the erlang-questions mailing list