[SR-Users] Kamailio number of matches of specific character in a string

Kristian F. Høgh kfh at uni-tel.dk
Thu Jun 18 13:04:56 CEST 2015


Hi,

This might get you started:
$var(test1)="bbbaddaa34";
$var(test2)=$(var(test1){s.replace,a,});    # replace "a" with nothing
$var(a)=$(var(test1){s.len});
$var(b)=$(var(test2){s.len});
$var(c)=$var(a) - $var(b);
xlog("$var(a), $var(b), $var(c)");

ERROR: <script>: 10, 7, 3

Regards,
Kristian Høgh
uni-tel A/S


On Thursday 18 June 2015 13:44:57 Ali Taher wrote:
> Hello,
> 
>  
> 
> I just need to count the number of a specific character in a string.
> 
> For example I want to count the number of "a" in the following string :
> "bbbaddaa34"
> 
>  
> 
> I searched among transformations but didn't find such tool.
> 
>  
> 
> Any help would be appreciated.
> 
>  
> 
> Thanks 
> 
> Ali
> 
>  
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20150618/7fe44310/attachment.html>


More information about the sr-users mailing list