[erlang-questions] regexp sux!

Christian S <>
Tue May 29 13:31:06 CEST 2007


Would it be easy to make regexps incremental, in such that i can
feed a regexp a string, and then find out if the string contained enough
for the regexp to match/halt, or if i need to continue feeding it with
more data.

Imagine I am receiving data blocks with an active gen_tcp socket, and
my potential regexp match is across the boundary of two received data
blocks.

I'm imagining an interface somewhat similar to md5_init/md5_update but
with an exit to let me know there was a match, at which point i would
get the matched part and the remaining part returned to me so i can
continue matching on the latter when i have processed the matched
block.

On 5/21/07, Darius Bacon <> wrote:
> Luke Gorrie <> wrote:
> > Darius Bacon <> writes:
> >
> > > Here's a lightly-tested hack -- I'm not familiar with the existing
> > > libraries so this is from scratch.
> >
> > You bloody showoff. :-) Works great!
>
> Guilty. :-)
>
> > I had to add . (dot) but nothing else really obvious is missing.
> > Feel free to draw my attention to anything I'm overlooking though :-)
>
> There's no attempt to conform to any standard, and the regex parser
> ought to be replaced with a real one that understands char ranges,
> inverted char classes, escaping, etc.
>
> > Can I steal this code and use it at work?
>
> Sure, I guess an MIT license would be appropriate. I'd appreciate
> getting back any improvements/tests -- don't know when I'll get around
> to the quickcheck tests.
>
> > NB: I would still feel more comfortable if this were quickcheck'd a
> > bit for divergence etc. I can't help but think that a free quickcheck
> > clone is likely to surface soon. I hope that John & Thomas are happy
> > with this idea or if not that they make their one accessible to us
> > random hackers on the list somehow soon :-)
>
> Their automatic error-case shrinking sounds really cool and useful.
>
> Darius
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list