[erlang-bugs] Bug with named subpatterns in re module

Sergei Golovan <>
Sun Mar 24 07:58:58 CET 2013


Chris King recently discovered a bug in re module. Appears that the
matched named subpatterns are not always returned.

The following command works correctly:
1> re:run("bar", "^(?<a>foo)(?<b>bla)$|^(?<a>[[:word:]]+)$",
[dupnames, {capture, [a, b], list}]).

But semantically the same one doesn't (note the swapped <a> and <b>):
1> re:run("bar", "^(?<b>foo)(?<a>bla)$|^(?<b>[[:word:]]+)$",
[dupnames, {capture, [a, b], list}]).

In both cases the second branch matches, but only the first command
returns the required subpattern.

The bug is reproducible in R16B.

Sergei Golovan

More information about the erlang-bugs mailing list