[erlang-questions] builtin regexp functions in Erlang/OTP R12B-3

Mats Cronqvist <>
Mon Jun 16 17:08:20 CEST 2008

Robert Virding wrote:
> All I can say is that I agree with Richard but expand more on it the EEP.
> One quick comment is that I wonder if not part of the problem with 
> PCRE and Perl regular expressions is that in one respect they are 
> integrated into Perl and contain features to interact with the rest of 
> Perl. If I remember correctly, for example, you can set Perl variables 
> directly from the RE. Is this what became the named subexprs in PCRE?

  AFAIK, perl does not use PCRE as its regexp engine. the PCRE wikipedia 
entry says;
 "The name is misleading, because PCRE is Perl-compatible only if you 
consider a subset of PCRE's settings and a subset of Perl's regular 
expression facilities."

  IMO, the main problem with PCRE is that it allows backreferences. as 
so eminently described by Russ Cox (*), this is an NP-complete problem. 
Cox says;
  "The simplest, most effective strategy for backreferences, taken by 
the original awk and egrep, is not to implement them."
  then he goes on to argue the opposite point;
  "This strategy is no longer practical: users have come to rely on 
backreferences for at least occasional use, and backreferences are part 
of the POSIX standard for regular expressions 

  i think not allowing backreferences is the correct choice for erlang. 
after all, erlang is about reliability. and it seems not being 
POSIX-compliant has worked for 20 years.
  OTOH, as is pointed out in EEP-11, PCRE has many nice features. but i 
vaguely remember that there was a flag that turned off backreferences....


p.s. there was a mail thread a couple of years ago, where i argued that 
a linking in PCRE was the way to go. we even implemented it, as a BIF (2).

(1) http://swtch.com/~rsc/regexp/regexp1.html

(2) http://www.erlang.org/pipermail/erlang-questions/2006-July/021556.html

More information about the erlang-questions mailing list