03.02.2011 19:08, Alex Folland пишет:
On 2011-02-03 10:21, Stanislav Blinov wrote:
03.02.2011 18:03, Alex Folland пишет:
I figured out the bug. Inside a set of square brackets, \s doesn't
match whitespace. It matches s instead. I'm uncertain exactly how the
ECMA-262 part 15.10 regular expression specification is meant to
handle that situation.
It does match for me:

foreach(m; match("a b c d e", regex("[a-z][\\s]?")))
{
writefln("%s[%s]%s", m.pre, m.hit, m.post);
}

Okay, now actually try the test I suggested. I found it was working in other sections too, but not in this test which has another "s" section it's supposed to look for.

Since it's broken, you'll see 2 matches instead of 1.

module main;

import std.stdio,std.regex;

void main()
{
foreach(m; match("9min59sec24", regex(`(\d+([\s_]|and|m(in(ute)?s?)?|s(ec(ond)?s?)?)*){1,3}`, "gi")))
    writefln("%s[%s]%s", m.pre, m.hit, m.post);
  return;


Oh, yes, I see it now.

Reply via email to