regex.d(6050): not enough preallocated memory
Paul
phshaffer at gmail.com
Tue Jun 5 13:25:55 PDT 2012
I am trying to see if all regex matches in one file are present
in another file.
The code works; but, part way through the nested foreach(s) I get
the error listed in the subject line. I would think this error
would come up when the Regex expressions were executed not when
I'm iterating through the resultant matches.
Is there a better way to do this or can I just allocate more
memory?
Thanks.
// Execute Regex expressions
auto uniCapturesOld = match(uniFileOld, regex(r"^NAME =
(?P<comp>[a-zA-Z0-9_]+):*(?P<blk>[a-zA-Z0-9_]*)","gm"));
auto uniCapturesNew = match(uniFileNew, regex(r"^NAME =
(?P<comp>[a-zA-Z0-9_]+):*(?P<blk>[a-zA-Z0-9_]*)","gm"));
// Iterate through match collections to see if both files contain
the same matches.
foreach (matchOld; uniCapturesOld) {
cntOld++;
found = false;
foreach (matchNew; uniCapturesNew) {
cntNew++;
// Following line is for troublshooting.
writeln(cntOld," ",cntNew," ",matchOld.hit,"
",matchNew.hit);
if (matchOld.hit == matchNew.hit) {found=true;break;}}
if (!found) writeln(cntNF++," ",matchOld.hit," not
found);}
More information about the Digitalmars-d-learn
mailing list