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

Sergei Golovan sgolovan@REDACTED
Thu Mar 28 17:52:56 CET 2013


Hi!

On Thu, Mar 28, 2013 at 8:13 PM, Patrik Nyblom <pan@REDACTED> wrote:
>
> Well, removing dupnames might be the easiest, but as there are perl
> semantics we can imitate, I think we should give it a try!

I should say that PCRE manual describes named subpatterns using the
following regexp:

(?<DN>Mon|Fri|Sun)(?:day)?|
(?<DN>Tue)(?:sday)?|
(?<DN>Wed)(?:nesday)?|
(?<DN>Thu)(?:rsday)?|
(?<DN>Sat)(?:urday)?

(search 'NAMED SUBPATTERNS' in http://www.pcre.org/pcre.txt). And currently

1> re:run("Monday",
"(?<DN>Mon|Fri|Sun)(?:day)?|(?<DN>Tue)(?:sday)?|(?<DN>Wed)(?:nesday)?|(?<DN>Thu)(?:rsday)?|(?<DN>Sat)(?:urday)?",
[dupnames, {capture, ['DN'], list}]).
{match,[[]]}

doesn't work. If I leave only one branch it works fine:
2> re:run("Monday", "(?<DN>Mon|Fri|Sun)(?:day)?", [dupnames, {capture,
['DN'], list}]).
{match,["Mon"]}

Cheers!
-- 
Sergei Golovan



More information about the erlang-bugs mailing list