pcre, bifs, drivers and ports

Mats Cronqvist mats.cronqvist@REDACTED
Wed Aug 2 16:07:15 CEST 2006


Luke Gorrie wrote:
> Bjorn Gustavsson <bjorn@REDACTED> writes:
> 
>> For instance, a long literal string is quite fast to match. An regexp
>> that uses the star (closure) operator, and especially multiple star
>> operators *can* be very slow. It depends on what the rest of the regexp
>> looks like and how clever the regexp engine is.
> 
> Yes. Extreme example:
> 
>   2> regexp:match("foo", "f**").
> 
>   Crash dump was written to: erl_crash.dump
>   eheap_alloc: Cannot allocate 1781763260 bytes of memory (of type "heap").
>   Aborted
> 
> .. death while trying to find the longest match with zero-or-more nothings.
> 
> I've often wondered if there's a simple fix for this that doesn't take
> away the cute simplicity of the regexp matcher.

   pcre deals with that like this;

1> re:grep("foo",["f**"]).
[{error,{"nothing to repeat",2}}]

   mats



More information about the erlang-questions mailing list