[Users] regexp and AVP problem

Norman Brandinger norm at goes.com
Tue Jul 18 17:12:03 CEST 2006


How does this work ?  It seemed to work for over here.

avp_subst("$avp(s:pai)/$avp(s:cli)","/<[[:blank:]]*tel\:([^[:blank:]]+)[[:blank:]]*>/\1/");

Regards,
Norm

Klaus Darilion wrote:
> Hi Norman!
>
> thanks - this works indeed. Now I wanted to tune it, so that it not 
> only removes spaces, but also tabs (according to posix this is 
> [:blank:]).
>
> For positive matching it works:
> /<[[:blank:]]*tel:([^ ]+)[[:blank:]]*>/\1/  --> OK
>
> But if I add this to the "negative matching" it fails:
> /<[[:blank:]]*tel:([^[[:blank:]]]+)[[:blank:]]*>/\1/ --> not OK
>                     ^^^^^^^^^^^^
> Do I need a special syntax for this?
>
> thanks
> klaus
>
> btw: I think escaping the colon is not necessary
>
>
> Norman Brandinger wrote:
>> Hi,
>>
>> Hope the regex below helps you out.
>>
>> avp_write("<    tel:+43108     >", "$avp(s:pai)");
>> avp_subst("$avp(s:pai)/$avp(s:cli)","/<[ ]*tel\:([^ ]+)[ ]*>/\1/");
>> xlog("L_NOTICE", "pai=($avp(s:pai)) cli=($avp(s:cli))\n");
>>
>> pai=(<    tel:+43108     >) cli=(+43108)
>>
>> Regards,
>> Norm
>>
>> Bogdan-Andrei Iancu wrote:
>>> no other clue in this case :(
>>>
>>> regards,
>>> bogdan
>>>
>>> Klaus Darilion wrote:
>>>
>>>> I tried ([^[[:blank:]]]*) but that did not worked too :-(
>>>>
>>>> regards
>>>> klaus
>>>>
>>>> Bogdan-Andrei Iancu wrote:
>>>>
>>>>> Hi Klaus,
>>>>>
>>>>> regexp tries to do the longest match for each token so the (.*) 
>>>>> will include also the trailing spaces.
>>>>> try not to put ., but everything except spaces, like  [^ ]*
>>>>>
>>>>> regards,
>>>>> bogdan
>>>>>
>>>>> Klaus Darilion wrote:
>>>>>
>>>>>> Norman Brandinger wrote:
>>>>>>
>>>>>>> Hi Klaus,
>>>>>>>
>>>>>>> Below is a little test I put together to try to help you out:
>>>>>>>
>>>>>>> avp_write("<tel:+43108>", "$avp(s:pai)");
>>>>>>> avp_subst("$avp(s:pai)/$avp(s:cli)","/<tel\:(.*)>/\1/");
>>>>>>> xlog("L_NOTICE", "pai=$avp(s:pai) cli=$avp(s:cli)\n");
>>>>>>>
>>>>>>> This is the result:
>>>>>>>
>>>>>>> pai=<tel:+43108> cli=+43108
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hi Norman. Yes, you are right. I simply had a wrong regular 
>>>>>> expression. But now I have another problem:
>>>>>>
>>>>>> Input: $avp(s:pai) = '<   tel:+43103   >'
>>>>>> (the part within '')
>>>>>>
>>>>>> avp_subst("$avp(s:pai)/$avp(s:paias)","/.*<[[:blank:]]*(.*?)[[:blank:]]*>.*/\1/") 
>>>>>>
>>>>>>
>>>>>> Output: $avp(s:paias) = 'tel:+43103   '
>>>>>>
>>>>>> Thus, the leading whitespace is removed, but not the trailing 
>>>>>> one, but I can't find an error in my regular expression. Maybe 
>>>>>> some regexp experts out there?
>>>>>>
>>>>>> thanks
>>>>>> klaus
>>>>>>
>>>>>>>
>>>>>>> Regards,
>>>>>>> Norm
>>>>>>>
>>>>>>> Klaus Darilion wrote:
>>>>>>>
>>>>>>>> Hi!
>>>>>>>>
>>>>>>>> I have problems with avp_subst:
>>>>>>>>
>>>>>>>> I have $avp(s:pai) with the value <tel:+43108> (the < and > 
>>>>>>>> belongs to the AVP)
>>>>>>>>
>>>>>>>> Then I want to extract the number into $avp(s:cli):
>>>>>>>>
>>>>>>>> avp_subst("$avp(s:pai)/$avp(s:cli)","/tel:(.*)/\1/")
>>>>>>>>
>>>>>>>> The result is <+43108>
>>>>>>>>
>>>>>>>> Can someone explain me why the leading < belongs to the result? 
>>>>>>>> Shouldn't it be removed?
>>>>>>>>
>>>>>>>> thanks
>>>>>>>> klaus
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Users mailing list
>>>>>>>> Users at openser.org
>>>>>>>> http://openser.org/cgi-bin/mailman/listinfo/users
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Users mailing list
>>>>>> Users at openser.org
>>>>>> http://openser.org/cgi-bin/mailman/listinfo/users
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>
>
>
>





More information about the sr-users mailing list