On 22/06/15 16:16, Daniel Tryba wrote:
> On Monday 22 June 2015 13:58:28 Ali Taher wrote:
>> I tried $var(pref)= $(var(a){s.select,0,#}); but I'm getting the whole
>> string if # doesn't exists.
>>
>> There is a way to check if # exists by subtracting  the  length of the
>> string  before and after removing # character and check if length changes ,
>> but I want a cost-less method.
> So just check for:
> $var(pref)= $(var(a){s.select,0,#});
> if($var(pref)==$var(a))
> {
>  var(pref)="";
> }
>
> This would cost near to nothing.
>
>
In general the operations in memory are very fast, so even on high load
you will barely notice any impact no mater the variant you try to use.

For sake of completion and showing alternatives, you can use regexp to
see if # is in the value or not:

if($var(a) =~ "#") {
  # - the char # is inside $var(a)
  ...
} else {
  ...
}

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Book: SIP Routing With Kamailio - http://www.asipto.com


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to