[prev in list] [next in list] [prev in thread] [next in thread]
List: sr-dev
Subject: Re: [Serdev] regexp stuff
From: Andrei Pelinescu-Onciul <pelinescu-onciul () fokus ! fraunhofer ! de>
Date: 2003-08-25 14:18:08
Message-ID: 20030825141808.GB10706 () fokus ! fraunhofer ! de
[Download RAW message or body]
On Aug 25, 2003 at 14:39, Jiri Kuthan <jiri@iptel.org> wrote:
> Juha,
>
> Andrei was kind enough to introduce support for such re-based
> replacement to the textops module in the development branch.
> The actions are called "subst" and "subst_uri".
>
> -jiri
>
>
> At 07:21 PM 5/4/2003, Juha Heinanen wrote:
> >>i needed to write some regexp functions for the new version of enum
> >>module that i coudn't find in any c libraries. basically the php
> >>function below is now done is c and it part of ser.
> >>
> >>i think it could be quite easily used to allow regexp replacement also
> >>in ser.cfg scripts. may be someone can implement that in the next next
> >>release.
The difference between your code and mine is I do "pre-compile" both the
REs and the replacement. It's better for script use: I do it only once
when the script is parsed and then I don't have to go char by char
through the replacement string again. The results of subst_run is
also "optimized" for easy conversion to struct lump.
Quick code usage example:
se=subst_parser(expr); /* where expr.s="/ab(c+)x/\1\u\n/ig"
rl=subst_run(se, input, msg);
/* convert rl to lumps */
or to get a str with input after running the RE on it:
se=subst_parser(expr);
s=subst_str(input, msg, se);
Texops script usage example:
subst('#^From:#f#ig'); /* on the entire message except the first line
(uri) */
subst_uri('/(sip:)([0-9]+)@/\1+\2@/i'); /* add a + in front of numbers*/
Supported escapes:
\n, \r
\u - message uri (any other suggestions?)
Andrei
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic