[erlang-bugs] regexp: no pattern matches empty string

Sverker Eriksson <>
Mon Jul 28 12:11:03 CEST 2008


Taisuke Hori wrote:
> Hello,
>
> I suspect a bug in regexp. I tried to match some patterns to a empty
> list, but they ware not matched.
>
> $ erl -version
> Erlang (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.5.5
> $ erl
> Eshell V5.5.5  (abort with ^G)
> 1> regexp:match("", "").
> nomatch
>   
Is an empty string really a valid regular expression? The new 
experimental module "re" in R12b-3, does not allow that:

1> re:run("", "").
** exception error: bad argument
     in function  re:run/2
        called as re:run([],[])

> 2> regexp:match("", ".*").
> nomatch
>   
This looks like a bug to me or at least like a strange behavior. "re" 
handles it well:

2> re:run("", ".*").
{match,[{0,0}]}


/Sverker, Erlang/OTP Ericsson




More information about the erlang-bugs mailing list