[sr-dev] regex's as PVs in textops functions

Daniel-Constantin Mierla miconda at gmail.com
Fri Jun 14 13:39:07 CEST 2013


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
>

-- 
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, San Francisco, USA - June 24-27, 2013
   * http://asipto.com/u/katu *




More information about the sr-dev mailing list