How to replace ALL matched sub strings with RegExpReplace?

How to replace ALL matched sub strings with RegExpReplace?

Hi,

I'm using ippsRegExpReplace_8u() to replace matched sub strings, but didn't find a way to replace *ALL* the matched sub strings. Following is an example.

regex: [BD]
src string: ABCDE
replacement: ##
wanted dist string: A##C##E
actual dist string: A##

How to write regex and replacement to get my wanted dist string? Or IPP just doesn't support that?

What's more, even IPP only supports replacing the first occurrence of the matched sub strings, I would expect the dist string to be "A##CDE"...

Thanks,
-Evan

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,
There is 'const char* pOptions' parameter in the function ippsRegExpInitAlloc. You can change search strategy by passing combination of 'i', 's', 'm', 'x', 'g' characters. By default first matched substring will be replaced. Please set in to the 'g'. 'g'is global search. That means all matched substrings will be replaced.

Igor S. Belyakov

Thanks, it works.

-Evan

Quote:

Igor Belyakov (Intel) wrote:

Hi,
There is 'const char* pOptions' parameter in the function ippsRegExpInitAlloc. You can change search strategy by passing combination of 'i', 's', 'm', 'x', 'g' characters. By default first matched substring will be replaced. Please set in to the 'g'. 'g'is global search. That means all matched substrings will be replaced.

Igor S. Belyakov

So please update the documentation because its othewise denoted:
"All found matches are replaced according to the replacement pattern that is stored in the structure pReplaceState."

Leave a Comment

Please sign in to add a comment. Not a member? Join today