UChar *mstart=(UChar*)szString,
*mend=(UChar*)szString + 2 * lstrlen(szString);
OnigRegion *region = onig_region_new();
// here's the interesting stuff
INT matches = 0, i;
while ( onig_search(regex, mstart, mend, mstart, mend, region, 0) GE 0 )
{
matches += 1;
// find the match and move past it
// first see if the match was a group
for ( i=1; i < region-GTnum_regs; i++ )
{
if ( region->beg[i] GE 0 ) // match was a group
{
mstart += region-GTend[i];
break; // keep looking (continue the while)
}
}
if ( i == region-GTnum_regs ) // match was not a group (region 0)
{
mstart += region-GTend[0];
}
// keep looking (continue the while)
}
Sprintf(psz, L"%d", matches);