Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
6632 Discussions

How to replace ALL matched sub strings with RegExpReplace?

evanyan
Beginner
135 Views
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
0 Kudos
3 Replies
Igor_B_Intel1
Employee
135 Views
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
evanyan
Beginner
135 Views
Thanks, it works.

-Evan
christian_s_7
Beginner
135 Views
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."
Reply