Counting number of regular expressions matches

Alain De Vos devosalain71 at gmail.com
Fri Apr 9 15:01:58 UTC 2021


I've got,
import std.regex: regex,matchAll;
...
string regfiltertext="\\b"~entryfilter.getText()~"\\b";
auto reg = regex(regfiltertext);
auto result = name.strip("_").matchAll(reg);
int t=0;
foreach (c; result) t+=1;

This make t the number of regular expressions matches.
Is there a better way to have the number of matches ?


More information about the Digitalmars-d-learn mailing list