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
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
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@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
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@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
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@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
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@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
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@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
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@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
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@openser.org > http://openser.org/cgi-bin/mailman/listinfo/users > > >
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
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@openser.org >> http://openser.org/cgi-bin/mailman/listinfo/users >> >> >> >
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Hi!
Meanwhile I splitted the regexp into several smaller ones nad now it works. But I found an interesting thing when removing blanks from an AVP:
This one works fine: avp_subst("$avp(s:pai)/$avp(s:painb)","/[[:blank:]]//g");
This one causes "out of mem": avp_subst("$avp(s:pai)/$avp(s:painb)","/[[:blank:]]*//g"); ^
07:17:46 server2 /usr/sbin/openser[6565]: subst_run: running. r=0 07:17:46 server2 /usr/sbin/openser[6565]: subst_run: matched (0, 0): [] 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: running. r=0 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: matched (0, 0): [] 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: running. r=0 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: matched (0, 0): [] 07:18:12 server2 /usr/sbin/openser[6565]: ERROR: replace_build: out of mem (rpl) 07:18:12 server2 /usr/sbin/openser[6565]: subst_str: no match 07:18:12 server2 /usr/sbin/openser[6565]: avpops:ops_subst: subst to 0 avps
regards klaus
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@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users
Hi Klaus,
the problem should be fixed on CVS - the cause was the invalid regexp: nothing (empty string) was matching (due the *) and this nothing was found infinitely in the string. This was leading to an infinite loop which was allocating private memory for replacing nothing with nothing :).....
regards, bogdan
Klaus Darilion wrote:
Hi!
Meanwhile I splitted the regexp into several smaller ones nad now it works. But I found an interesting thing when removing blanks from an AVP:
This one works fine: avp_subst("$avp(s:pai)/$avp(s:painb)","/[[:blank:]]//g");
This one causes "out of mem": avp_subst("$avp(s:pai)/$avp(s:painb)","/[[:blank:]]*//g"); ^
07:17:46 server2 /usr/sbin/openser[6565]: subst_run: running. r=0 07:17:46 server2 /usr/sbin/openser[6565]: subst_run: matched (0, 0): [] 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: running. r=0 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: matched (0, 0): [] 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: running. r=0 07:18:12 server2 /usr/sbin/openser[6565]: subst_run: matched (0, 0): [] 07:18:12 server2 /usr/sbin/openser[6565]: ERROR: replace_build: out of mem (rpl) 07:18:12 server2 /usr/sbin/openser[6565]: subst_str: no match 07:18:12 server2 /usr/sbin/openser[6565]: avpops:ops_subst: subst to 0 avps
regards klaus
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