[SR-Users] help with regex extracting from $rb
Sergiu Pojoga
pojogas at gmail.com
Mon Oct 29 18:33:55 CET 2018
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
CallID:1ca9258d285a539e3c1048205bf38d41 at mypb.net
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20181029/877ccf43/attachment.html>
More information about the sr-users
mailing list