[Serusers] truncating long phone numbers?

Andrei Pelinescu-Onciul pelinescu-onciul at fokus.fraunhofer.de
Thu Sep 23 09:37:12 CEST 2004


On Sep 22, 2004 at 14:03, Jeremy M. Dolan <jmd at pobox.com> wrote:
> Hello, serusers!
> 
> I am trying to add support to our SER routing to do the right thing
> when users add extra digits to phone numbers. We have silly users
> trying to dial 1-800-JABBER-WOCK type numbers, and they don't know to
> stop dialing after the "W", since you don't need to on a standard
> analog line.
> 
> It seems like this would either require a reg-exp back reference
> (ie, \1), or a while loop and a function like strip() that works on
> the other side of the user portion of the SIP address:

try subst_uri from the textops modules.
Example from textops/README:
( subst_uri('/re/repl/flags') ):

  if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:3463\1@\2;orig_uri=\0/i')){$

  ...

 
> 
> while (uri =~ ^sip:[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]) {
> 	endstrip(1);
> }
> 
> Are any of these functions available, but not documented? I've found
> the language reference/Admin's guide to be a bit obscure at times for
> discovering these sorts of things. Or can anyone suggest another way
> to truncate the number down?
> 
> Also, as long as I'm writing in: are there any minimum and maximum
> quantifiers (ie, [0-9]{3,5}) available in SER? It's hard to read code
> that's 90% repeated character classes!

Yes, they should work in all the regular expressions.
(e.g.: uri =~ "sip:[0-9]{2,7}")


Andrei




More information about the sr-users mailing list