May be for a start someone can clarify the general rules of engagement in this battle with regex transformations.
https://www.kamailio.org/wiki/cookbooks/5.1.x/transformations#resubst_expression

What kind of regex library does this function expect: PCRE, Perl, Java, POSIX BRE/ERE?
I've used all kinds of regex validators, regex101.com, rexv.org. Some expressions pass those but do not work in Kamailio. The result is a dump of the entire $rb.

Much obliged.

On Mon, Oct 29, 2018 at 1:33 PM Sergiu Pojoga <pojogas@gmail.com> wrote:
Hi there,

May be some regex gurus can help me out. Being aware that regex's are tricky but not seeing another alternative in this particular case.

Trying to extract MOSLQ field from $rb.

$var(moslq) = $(rb{re.subst,/.*MOSLQ=([0-9].[0-9])\s+MOSCQ=([0-9].[0-9]).*/\1/s});

Above regex works fine IF body contains a single matching line. However, if there's 2 lines as in the below example - it return $var(moslq)=0.0, the last found value.

I need only LocalMetrics values, so I tried this regex which works fine in regex101.com with flag 'multi-line' and without flag 'global', but doesn't work in Kamailio.
$var(moslq) = $(rb{re.subst,/.*MOSLQ=([0-9].[0-9])\s+MOSCQ=([0-9].[0-9])[\nRemoteMetrics]?.*/\1/s});

Assuming $rb is as follows:
VQSessionReport
LocalMetrics:
Timestamps:START=2018-10-29T15:04:38Z STOP=2018-10-29T15:06:13Z
QualityEst:EXTRI=127 MOSLQ=4.2 MOSCQ=4.4
RemoteMetrics:
Timestamps:START=2018-10-29T15:04:38Z STOP=2018-10-29T15:06:13Z
QualityEst:RCQ=0 EXTRI=0 MOSLQ=0.0 MOSCQ=0.0

Thanks in advance.