regexp bug (literal dot)

Luke Gorrie <>
Tue Mar 26 10:14:31 CET 2002


Chris Pressey <> writes:

> On Mon, 25 Mar 2002 23:57:28 +0100
> Willem Broekema <> wrote:
> 
> > Hi all,
> > 
> >  From what I understand, in regexps, "." means 'any char' and "\." means
> >  a literal dot.
> > 
> > So, the following is a bug:
> > 
> > 170> regexp:match("a", ".").
> > {match,1,1}
> > 
> > 171> regexp:match("a", "\.").
> > {match,1,1}  % shouldn't match!
> > 
> > 
> > - Willem
> 
> Erlang strings are quoted as well as regexps, so you probably want
> 
>   regexp:match("a", "\\.").

Another bug candidate:

  regexp:match("foo", ".**").

Which doesn't terminate, because it tries to match 0x zero chars, then
1x zero chars, then 2x zero chars, etc.

Maybe useful the next time you need to do a denial-of-service attack
on an Erlang program :-) since this will make the emulator keep
allocating until the OS runs out of virtual memory.

Cheers,
Luke




More information about the erlang-questions mailing list