Hello,
On 5/7/12 8:57 PM, Juha Heinanen wrote:
Richard Fuchs writes:
I know that, but that doesn't answer my question. :) Regex substitutions work the same everywhere, s/(.)/\1/ in sed or Perl for example leaves the string unchanged. Why is the dialplan module different?
are you sure that (.) does the trick? i have used (.*) and that works ok.
indeed the .* is at least the posix standard way to match everything, '.' being for matching one single character.
Replacements in configuration file/dialplan do not use external library for substitution, only for matching (posix regexp for core/textops which is in libc and libpcre for dialplan). The replacement itself is made via a function from the core (iirc, Andrei Pelinescu-Onciul implemented it in the very early days of ser).
I am not that familiar with perl/sed and their full substitution rules, but in Kamailio, practically the subst_exp is supposed to break the matched value in tokens and then back-references in repl_exp can be used to build the new value.
Maybe I got used to this kind of model, to group parts of matches values and everything went fine for me.
For what Andreas exemplified in the first email in this thread, I would have used:
subst="^999(.*)" repl="\1"
I would consider a bug if there is no way to remove the full value (i.e., set the result to empty string), like no change will happen with: subst="(.*)" repl=""
Personally, I would not mind an update to get to a more common behaviour, if it will be properly documented and referenced to other well established languages/tutorials. So far the term was 'perl-like substitutions' not 'perl substitutions' more for syntax/idea. Also, we have our specific behaviour, the repl expression can include cfg variables (e.g., $avp(...), $var(...), ...) that are expanded when building the result.
However, I think it is too late for 3.3.0, because it will introduce lot of changes, perhaps many in the behaviour as well, and we are already 2 weeks in the testing phase.
Cheers, Daniel