[erlang-questions] improving the performance of regexp(regular expressions)

David Mitchell monch1962@REDACTED
Fri Jul 4 04:33:06 CEST 2008

Others are probably going to say this as well, but my experience with
Erlang is that it isn't great for regex.  It's great for a lot of
other things, but not regex (yet!).

Pre-R12B-3, I had a lot of success using pattern matches in situations
where my initial reaction was to use regex.  While it was a bit more
code, it was a lot easier to comprehend than regex code and, through
using a layer of fun() calls, it ran blazingly fast.  For the specific
project, I had to do a lot of (pattern matching|regex) *and* have it
run as quickly as possible; from a coding perspective, what I lost in
having to put together a bunch of pattern matches (in place of what
would have been a single regex in e.g. Perl), I got back many times
over in terms of performance in the finished product.

Now that R12B-3 is here, I'll probably look at the re changes, but
I've now got some experience that tells me that regex isn't the be-all
and end-all of data parsing solutions.  If you've got the chance, you
might find it's worth looking at what you can do with pattern matching
in place of regex.


Dave M.

2008/7/1 Jesper Louis Andersen <jesper.louis.andersen@REDACTED>:
> 2008/7/1 chamila piyasena <tchamila@REDACTED>:
>> Hi all,
>> Is there a new implementation of regexp.erl or can anyone suggest a way to
>> improve the performance of the functionalities given in the regexp.erl
>> without using regexp library written in C.
> Seriously: Consider something else than regular expressions if it is
> possible. Some languages, most notably perl has used regular
> expressions extensively and thus has a pretty fast implementation of
> them. But usually you can easily write code without them. Maybe you
> can read the data in a more structured format, maybe you can
> pre-process the data into a simpler format or maybe you can skip parts
> of the data.
> Rather than trying to brute-force yourself through the mouse-hole, use
> the door in the wall ;)
> Regular expressions have their uses, but they indeed also have their abuses.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list