<br><br><div class="gmail_quote">On Wed, May 21, 2008 at 10:02 PM, Igor Ribeiro Sucupira <<a href="mailto:igorrs@gmail.com">igorrs@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Wed, May 21, 2008 at 4:48 PM, Pablo Polvorin<br>
<<a href="mailto:pablo.polvorin@gmail.com">pablo.polvorin@gmail.com</a>> wrote:<br>
</div><div class="Ih2E3d">> Hello,<br>
> instead of regular expression, I would suggest to use pattern matching instead:<br>
> 1> A = <<"OK 01 xxxxxxxx\r\n">>.<br>
> <<"OK 01 xxxxxxxx\r\n">><br>
> 2> <<"OK 01",X/binary>> = A.<br>
<br>
</div>List equivalent would be something like:<br>
"OK 01 " ++ UnknownPart = Str<br>
<br>
The difference from my other suggestion would be that you're now<br>
checking if the strings starts with "OK 01 ", instead of just cropping<br>
the first 6 characters.</blockquote><div><br><br>Hi,<br>only with OK 01 i've to read the next chars. In my other protocol i've got other OK response but they are use for tracing the state of my app, and i don't need to read the other chars.<br>
<br>M.Canato<br><br><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<font color="#888888"><br>
Igor.<br>
</font><div class="Ih2E3d"><br>
> <<"OK 01 xxxxxxxx\r\n">><br>
> 3> X.<br>
> <<" xxxxxxxx\r\n">><br>
><br>
> besides that, if what you are parsing is some sort of network<br>
> protocol, you won't want to represent strings as lists(), but use<br>
> binaries like in the previous example.<br>
><br>
><br>
> 2008/5/21, Matteo <<a href="mailto:mcanato@gmail.com">mcanato@gmail.com</a>>:<br>
>> Hi to all,<br>
>> i'm a noob of erlang programming. I would like to have some infos about<br>
>> extracting a substring from a string....<br>
>> Or better, my situation is this:<br>
>><br>
>> i have a string:<br>
>> str="OK 01 xxxxxxxx\r\n"); // where xxxxxxxx is a string that i dont know<br>
>> and every time change...<br>
>><br>
>> and i need to extract the "xxxxxxx" into another string (str2 for exaple).<br>
>><br>
>> Sorry for my english.<br>
>><br>
>> Best regards<br>
>> M.Canato<br>
>><br>
><br>
><br>
> --<br>
> --<br>
> pablo<br>
> <a href="http://ppolv.wordpress.com" target="_blank">http://ppolv.wordpress.com</a><br>
> ----<br>
</div><div><div></div><div class="Wj3C7c">> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
</div></div></blockquote></div><br>