digitalmars.D.learn - How can I walk the list in a RegexMatch backwards?
- Chris Bare (9/9) Feb 03 2019 auto matches = matchAll(str, searchRegex);
- Jordan Wilson (6/15) Feb 03 2019 matchAll is a forward range, whereas retro requires a
auto matches = matchAll(str, searchRegex); foreach (m; matches) // this walks the list forward I tried: foreach_reverse (m; matches) foreach (m; reverse (matches)) foreach (m; retro (matches)) and they all failed to compile. I also tried to index matches (matches[i]) but that does not work either.
Feb 03 2019
On Sunday, 3 February 2019 at 18:07:13 UTC, Chris Bare wrote:auto matches = matchAll(str, searchRegex); foreach (m; matches) // this walks the list forward I tried: foreach_reverse (m; matches) foreach (m; reverse (matches)) foreach (m; retro (matches)) and they all failed to compile. I also tried to index matches (matches[i]) but that does not work either.matchAll is a forward range, whereas retro requires a bi-directional range. So using the array function should work: foreach (m; matches.array.retro) Jordan
Feb 03 2019