regex matching but not capturing

Paul phshaffer at gmail.com
Thu Apr 6 15:52:16 UTC 2023


My regex is matching but doesnt seem to be capturing.  You may 
recognize this from the AOC challenges.

file contains...
**Valve AA has flow rate=0; tunnels lead to valves DD, II, BB**
**Valve BB has flow rate=13; tunnels lead to valves CC, AA**
**Valve CC has flow rate=2; tunnels lead to valves DD, BB**
**... etc**

```d
auto s = readText(filename);
auto ctr = ctRegex!(`Valve ([A-Z]{2}).*=(\d+).+valves(,* 
[A-Z]{2})+`);
foreach(c;matchAll(s, ctr)) {
	fo.writeln(c);
}
```

produces...
**["Valve AA has flow rate=0; tunnels lead to valves DD, II, BB", 
"AA", "0", ", BB"]**
**["Valve BB has flow rate=13; tunnels lead to valves CC, AA", 
"BB", "13", ", AA"]**
**["Valve CC has flow rate=2; tunnels lead to valves DD, BB", 
"CC", "2", ", BB"]**

what I'm attempting to achieve and expect is, for instance, on 
the 1st line...
[....lead to valves DD, II, BB", "AA", "0", **", DD", ", II", ", 
BB"]**


More information about the Digitalmars-d-learn mailing list