[Users] regular expression

Edson 4lists at gmail.com
Thu Nov 30 18:18:12 CET 2006


First thinks first: please don't forget to CC the list.. Any information can
be for others help. ;)

 

Well, I would suggest You to make some tests on a command line simulation to
be sure what You want to accoplish is even possible. Something like this:

 

# echo "sip:112345678#@10.10.10.10" | grep -E
"^sip:1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]@"

# echo "sip:112345678#@10.10.10.10" | grep -E
"^sip:1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\@"

# echo "sip:112345678#@10.10.10.10" | grep -E
"^sip:1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"

sip:112345678#@10.10.10.10

# echo "sip:112345678 at 10.10.10.10" | grep -E
"^sip:1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\@"

sip:112345678 at 10.10.10.10

# echo "sip:112345678 at 10.10.10.10" | grep -E
"^sip:1[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]@"

sip:112345678 at 10.10.10.10

#

 

As OpenSER, and SER as origin, use a regular expression as GREP, You could
see that it work like You asked for.

 

I also run a test in a SER leaving here. I put this code:

 

                } else if (uri=~"^sip:1[0-9]{8}@") {
# Test for "1xxxxxxxx" mask numbers

                        strip(9);

                        prefix("600");

                        route(6);

                        break;

                }

 

And when I call 112345678 from my Softphone, ngrep shows me this forwarded
INVITE:

 

  INVITE sip:600 at pstn.gw:5060 SIP/2.0..Record-Route:
<sip:sip.proxy;ftag=1468362515290;lr=on>..Via: SIP/2.0/UDP
sip.proxy;branch=z9hG4bK90b1.5f

  c55385.0..Via: SIP/2.0/UDP
client.ip;received=sip.client;rport=1024;branch=z9hG4bKac1bf8060000010f456ef
12a000028cf00000158..From: "Edson -

  SJPhone"<sip:8201 at sip.proxy>;tag=1468362515290..To:
<sip:112345678 at sip.proxy>..Contact: <sip:8201 at sip.client>..Call-ID:
647DD163-9B1E-45DB-93A2-99

  CAC53532B8 at client.ip..CSeq: 2 INVITE..Max-Forwards: 16..User-Agent:
SJphone/1.61 (SJ Labs)..Content-Length: 217..Content-Type:
application/sdp....v=0

  ..o=- 3373887402 3373887402 IN IP4 sip.client..s=SJphone..c=IN IP4
sip.client..t=0 0..a=setup:active..m=audio 49186 RTP/AVP 4 101..a=rtpmap:4
G723/8000

  ..a=rtpmap:101 telephone-event/8000..a=fmtp:101 0-11,16..

 

Which in case is what we are looking for. Identified and translate any 9
digit number, started with '1' to '600'.

 

Hope that this help You understand all the mechanism.

 

Edson.

 

  _____  

From: raviprakash sunkara [mailto:sunkara.raviprakash.feb14 at gmail.com] 
Sent: quinta-feira, 30 de novembro de 2006 01:24
To: Edson
Subject: Re: [Users] regular expression

 

Hello Edson, 



On 11/29/06, Edson <4lists at gmail.com> wrote:

Opppsss.... 

 

I think that You make a little typo....

 

Wouldn't the correct be "^sip:1[0-9]{8}@" to match all numbers with 9 digits
initiated by an '1' and followed by any combination of digits (from '0' to
'9')?


this Regular epression is   sip:1[0-9]{8}  correct  but...... if the number
like this ... 112345678# 
The Red color one must  be the digit , not any any special charecter.......
According u reg expression .. 

So,,, i'm sure ..................... like this it must ..........
sip:1{8}[0-9}............

Sorry , if i did any thing mistake......excuse me......... 

 

Edson

 


  _____  


From: users-bounces at openser.org [mailto: <mailto:users-bounces at openser.org>
users-bounces at openser.org] On Behalf Of raviprakash sunkara
Sent: quarta-feira, 29 de novembro de 2006 11:35
To: Jayesh Nambiar
Cc: Users at openser.org
Subject: Re: [Users] regular expression

 

 



On 11/29/06, Jayesh Nambiar <voip_freak at yahoo.co.in
<mailto:voip_freak at yahoo.co.in> > wrote:

Hi all,
Can someone please help me in formulating a regular expression. I have an
expression like this:
if(uri=~"^sip:1[0-9]*@) 
This matches numbers like 15552221212, but also matches number like
15552221212#.

when i make it as:
if(uri=~"^sip:1[0-9]@*)


Use this 
if (uri=~"^sip:1{8}[0-9]@" ) 


 

 

Again this matches any special characters after the number.

I just wanted a regular expression that will match only numbers and no
alphabets or special characters.
Can someone please help me to formulate a regular expression for this. 

Thanks in advance.

w/regards,
Jayesh

 


  _____  


Find out what India is talking about on - Yahoo! Answers India
<http://us.rd.yahoo.com/mail/in/yanswers/*http:/in.answers.yahoo.com/>  
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get
it NOW
<http://us.rd.yahoo.com/mail/in/messengertagline/*http:/in.messenger.yahoo.c
om> 


_______________________________________________
Users mailing list
Users at openser.org
http://openser.org/cgi-bin/mailman/listinfo/users




-- 
Thanks and Regards
Ravi Prakash Sunkara 
ravi.sunkara at hyperion-tech.com 
M:+91 9985077535
O:+91 40 23114549
F:+91 40 40208727 
ravi.sunkara at hyperion-tech.com 
www.hyperion-tech.com  <http://www.hyperion-tech.com> 




-- 
Thanks and Regards
Ravi Prakash Sunkara 
ravi.sunkara at hyperion-tech.com 
M:+91 9985077535
O:+91 40 23114549 
F:+91 40 40208727 
ravi.sunkara at hyperion-tech.com
www.hyperion-tech.com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20061130/a071eb02/attachment.htm>


More information about the sr-users mailing list