RegExpReplace and NumFind

RegExpReplace and NumFind

Hi,

I am using IPP 7.0 and i got a issue with ippsRegExpReplace.

The core of the function is have written is the following while loop:

while (searched_length < src_len) {
        len= src_len - searched_length;
        istatus= ippsRegExpReplace_8u((const Ipp8u*)(src + searched_length),
                &len, (Ipp8u*)(dst + replaced_length), &dst_len, iFind, &iNumFind,
                o->ires, irers);
        searched_length+= len;
        replaced_length+= dst_len;
}

When I compile with pattern "g" with global flag and do a replace with the sourcestring pSrc="gggggggggggggggggggggggggg" (26 * "g") and a iNumFind= 25, i get the output:
searched_length= 26 (the whole string is searched)
replaced_length= 26
pNumFind= 25
dst="#########################g"

Shouldn't have been replaced all g's in the source string? iNumFind is 25 on input and all 25 substrings are replaced but there are 26 substrings found and the regex searches through the whole string and not stopping at the 25th match. How can i replace all substrings?

regards Chris

2 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Hello,

A few comments from our experts on this problem:

There are two possible error conditions during global search and replace. And they shall be resolved in this fixed order.
1.Search problem: pFind array has got size less than expected.
In that case function returns ippStsOverlow status and fills dest data as much as possible. Need to extend pFind size.
2.Replace problem: dest buffer has got size less than expected.
In that case function returns ippStsOk but srcLenUsed value less than srcLen. Need to extend dest array size.

Thanks,
Chao

Connectez-vous pour laisser un commentaire.