[erlang-questions] regular expressions on binaries
Robert Virding
rvirding@REDACTED
Sun Aug 26 03:43:45 CEST 2007
I am working on a new regexp module which will work directly on binaries.
Hopefully soon done. First version will have POSIX regexps.
Robert
On 26/08/07, Paul Mineiro <paul-trapexit@REDACTED> wrote:
>
> I don't think I do.
>
> For instance: to implement "FOO(a|b)*BAR" I would write:
>
> --------
>
> match_start (<<>>, _) -> nomatch;
> match_start (<<"FOO", R/binary>>, pos) -> match_end (R, pos, pos + 3);
> match_start (<<_:8, R/binary>>, pos) -> match_start (R, pos + 1).
>
> match_end (<<>>, _, _) -> nomatch;
> match_end (<<"BAR", _/binary>>, start, end) -> { match, start, end };
> match_end (<<$a:8, R/binary>>, start, end) -> match_end (R, start, end +
> 1);
> match_end (<<$b:8, R/binary>>, start, end) -> match_end (R, start, end +
> 1).
>
> --------
>
> To me that's seems tedious, likely to be incorrect (especially for more
> complicated patterns), and better done by a library.
>
> Is there a better way?
>
> -- p
>
>
> On Sat, 25 Aug 2007, Ben Munat wrote:
>
> > I think you just want pattern matching on binaries:
> >
> >
> http://erlang.org/documentation/doc-5.4.12/doc/programming_examples/bit_syntax.html
> >
> > b
> >
> >
> > Paul Mineiro wrote:
> > > Is there an analog to regexp available that works on binaries?
> > >
> > > Thanks in advance,
> > >
> > > -- p
> > > _______________________________________________
> > > erlang-questions mailing list
> > > erlang-questions@REDACTED
> > > http://www.erlang.org/mailman/listinfo/erlang-questions
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070826/6eb2eef3/attachment.htm>
More information about the erlang-questions
mailing list