Hello, I need to run a text find-and-replace on the body of my requests and responses. The texops functions 'replace_body_all' and 'subst_body' work for fixed regular expressions, but mine need to be configurable i.e. loaded from a database. Trying to accept PVs in the regex parameter could intefere with regex's that contain $ characters, so this isn't as simple as inserting the spve fixup into these functions.
What do you think is the best way to implement this and remain compatible with existing versions? New functions with different names?
For example: route(FETCH_REGEX_FROM_DB); if ($var(regex) != $null) { replace_body_pv("$var(regex)", "$var(repl)"); }
Regards, Hugh
Hello,
On 6/13/13 5:14 PM, Hugh Waite wrote:
Hello, I need to run a text find-and-replace on the body of my requests and responses. The texops functions 'replace_body_all' and 'subst_body' work for fixed regular expressions, but mine need to be configurable i.e. loaded from a database. Trying to accept PVs in the regex parameter could intefere with regex's that contain $ characters, so this isn't as simple as inserting the spve fixup into these functions.
What do you think is the best way to implement this and remain compatible with existing versions? New functions with different names?
I would go for using a different name. Existing ones do the fixup at startup, compiling the parameter to a regex structure. For the new function that has to be done at runtime and the structure freed as well.
Cheers, Daniel
For example: route(FETCH_REGEX_FROM_DB); if ($var(regex) != $null) { replace_body_pv("$var(regex)", "$var(repl)"); }
Regards, Hugh