string manipulation

Stefan Paetow Stefan.Paetow at jisc.ac.uk
Tue Sep 6 13:59:53 CEST 2016


> The data in Asterisk-Last-Data is something like
> SIP/7874338439 at SIPprovider.
> 
> I would like to save only the 7874338439 data in Called-Station-Id.

If the string is fairly constant in format, i.e. it's always 'SIP/<numbers>@SIPProvider', then I'd try:

if (&request:Asterisk-Last-Data =~ /\/([0-9]+)\@/) {    # a series of digits preceded by a / and followed by an @
    update reply {
        Called-Station-Id := "%{1}"
    }
}

Does that work for you? :-)

Stefan Paetow
Moonshot Industry & Research Liaison Coordinator

t: +44 (0)1235 822 125
gpg: 0x3FCE5142
xmpp: stefanp at jabber.dev.ja.net
skype: stefan.paetow.janet

jisc.ac.uk

Jisc is a registered charity (number 1149740) and a company limited by guarantee which is registered in England under Company No. 5747339, VAT No. GB 197 0632 86. Jisc’s registered office is: One Castlepark, Tower Hill, Bristol, BS2 0JA. T 0203 697 5800.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20160906/546e1709/attachment.sig>


More information about the Freeradius-Users mailing list