Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
virtual P6R::P6ERR P6R::p6IRegex::replaceWithCallback ( const P6CHAR pSearch,
P6REGEXMODIFIER  modifiers,
P6REGEXREPLACECB  pfn,
P6VOID pCtx,
p6IRegexMatch **  pResult 
)
pure virtual

Replaces the first matching subexpressions in the pSearch string with a replacement string provided as the resultof a callback function.

Replaces all occurrances if the MODIFIER_GLOBAL flag is passed in the "modifiers" paramater. Places the resulting string in the pResult buffer passed in by the caller. Note, that the 'compile' function must be called before this function. If the component was created with the trace option then the evalution steps will be detailed logged.

The benefit of this function is that the replacement string is not fixed but provided by the calling application via a callback function and can be different for each subexpression match.

Meaningful modifiers: { P6MODIFIER_INSENSITIVE, P6MODIFIER_FASTGREEDY, P6MODIFIER_MULTILINE, P6MODIFIER_GLOBAL }

Parameters
pSearch[ in ] The string to test against the compiled regular expression.
modifiers[ in ] A bit mask that defines how the regex engine performs the match
pfn[ in ] Pointer to a callback function to be invoked each time a match is found in the pSearch parameter. The callback function returns the string to replace the matched subexpression with. This string can have back references in it (e.g., "--\1--\2"). The back references are evaluated after each match for global matches.
pCtx[ in ] Can be NULL, pointer to a context that is passed to the pfn callback each time to get the replacement string from the application. This memory is allocated and freed only by the caller.
pResult[ out ] The final result string with all replacements done.
Returns
SuccessP6R::eOk 
FailureP6R::eNotInitializedA successful call to initialize was not made before this call.
P6R::eInvalidArgOne or more of pSearch, pReplace, and pSize is set to NULL.
P6R::eAccessFaultThe compile function has not be successfully called.
P6R::eNoMemoryInsufficent memory to process the regex.