I am working on a new regexp module which will work directly on binaries. Hopefully soon done. First version will have POSIX regexps.<br><br>Robert<br><br>On 26/08/07, <b class="gmail_sendername">Paul Mineiro</b> <<a href="mailto:paul-trapexit@mineiro.com">
paul-trapexit@mineiro.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I don't think I do.
<br><br>For instance: to implement "FOO(a|b)*BAR" I would write:<br><br>--------<br><br>match_start (<<>>, _) -> nomatch;<br>match_start (<<"FOO", R/binary>>, pos) -> match_end (R, pos, pos + 3);
<br>match_start (<<_:8, R/binary>>, pos) -> match_start (R, pos + 1).<br><br>match_end (<<>>, _, _) -> nomatch;<br>match_end (<<"BAR", _/binary>>, start, end) -> { match, start, end };
<br>match_end (<<$a:8, R/binary>>, start, end) -> match_end (R, start, end + 1);<br>match_end (<<$b:8, R/binary>>, start, end) -> match_end (R, start, end + 1).<br><br>--------<br><br>To me that's seems tedious, likely to be incorrect (especially for more
<br>complicated patterns), and better done by a library.<br><br>Is there a better way?<br><br>-- p<br><br><br>On Sat, 25 Aug 2007, Ben Munat wrote:<br><br>> I think you just want pattern matching on binaries:<br>><br>
> <a href="http://erlang.org/documentation/doc-5.4.12/doc/programming_examples/bit_syntax.html">http://erlang.org/documentation/doc-5.4.12/doc/programming_examples/bit_syntax.html</a><br>><br>> b<br>><br>><br>
> Paul Mineiro wrote:<br>> > Is there an analog to regexp available that works on binaries?<br>> ><br>> > Thanks in advance,<br>> ><br>> > -- p<br>> > _______________________________________________
<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">http://www.erlang.org/mailman/listinfo/erlang-questions
</a><br>> _______________________________________________<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">
http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>><br>_______________________________________________<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">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>