Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
Regular expression with "\d" operator.
Author Message
tuctran
Brekeke Junior Member


Joined: 04 Sep 2014
Posts: 8

PostPosted: Sun Jun 14, 2015 6:08 pm    Post subject: Regular expression with "\d" operator. Reply with quote

1. Brekeke Product Name and Version: Brekeke SIP SEVER, 3.4.x.x release

2. Java version: 1.8.0_45

3. OS type and the version: 8.1

4. UA (phone), gateway or other hardware/software involved: does not master

5. Your problem:
I create below rule to check a NOTIFY message then inform to user for a number of new voicemail messages come to his mailbox. A number of new voiemail message is filtered out from NOTIFY message by this expression "expression $body("Voice-Message: (\d+)/") = (.+)". But this expression always returns a null value instead of a number (4) as I expect from this body content "Voice-Message: 4/0 (0/0)".
Could any one tell me if any thing wrong with the expression. Please see below for detail of the problem.

Thanks,
======================================================
Create below dial plan rule:
Rule name: "PN3_NotifyVoiceMes"
Matching Patterns
$request = ^NOTIFY
$getSIPuser(To) = (.+)
$pn.user("%1") = true
Content-Type = application/simple-message-summary
$body("Messages-Waiting: (.+)") = yes
$body("Voice-Message: (\d+)/") = (.+)
Deploy Patterns
&pn.notify.user = %1
&pn.notify.message = You got new voice message
$pn.notify.counter = %2
$continue = true


*Below is actual NOTIFY message I got.
============
NOTIFY Message:
NOTIFY sip:1003@127.0.0.1 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5054;rport=5054;branch=z9hG4bKc5b4f5dbe82b
From: sip:1003@127.0.0.1;tag=b26505fa7p
To: <sip:1003@127.0.0.1>
Max-Forwards: 20
Contact: <sip:127.0.0.1:5054>
Call-ID: 9ed9392b-463ebb8d-7da3c79-e8e3b40b
User-Agent: Brekeke PBX
CSeq: 1 NOTIFY
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: 85

Messages-Waiting: yes
Message-Account: sip:8@192.168.0.3
Voice-Message: 4/0 (0/0)


=> With the input "Voice-Message: 4/0 (0/0)". The expression "$body("Voice-Message: (\d+)/") = (.+)" should return "4" instead of "null"

*Detail log:
============================================
Rule [PN3_NotifyVoiceMes]

Pattern: $request = ^NOTIFY
Input: $request = NOTIFY sip:1005@127.0.0.1 SIP/2.0
Result: true

Pattern: $getSIPuser(To) = (.+)
Input: $getSIPuser(To) = 1005
%1 <= 1005
Result: true

Pattern: $pn.user("%1") = true
Input: $pn.user("1005") = true
Result: true

Pattern: Content-Type = application/simple-message-summary
Input: Content-Type = application/simple-message-summary
Result: true

Pattern: $body("Messages-Waiting: (.+)") = yes
Input: $body("Messages-Waiting: (.+)") = yes
Result: true

Pattern: $body("Content-Length: (\d)") = (.+)
Input: $body("Content-Length: (\d)") = null
Result: false
============================================
Back to top
View user's profile
Harold
Brekeke Master Guru


Joined: 21 Sep 2008
Posts: 287
Location: Japan

PostPosted: Mon Jun 15, 2015 3:16 pm    Post subject: Reply with quote

Which Voicemail system are you using?
Is it Brekeke PBX? or 3rd product?

If you are talking about Brekeke PBX, let you post the question at the PBX Forum. http://www.brekeke-sip.com/bbs/viewforum.php?f=33

if you are using 3rd product, let me know the product name.
Back to top
View user's profile
Harold
Brekeke Master Guru


Joined: 21 Sep 2008
Posts: 287
Location: Japan

PostPosted: Mon Jun 15, 2015 3:33 pm    Post subject: Reply with quote

Have you applied the DialPlan rule?

According to the log, you used $body("Content-Length: (\d)") instead of $body("Voice-Message: (\d+)/").
Back to top
View user's profile
tuctran
Brekeke Junior Member


Joined: 04 Sep 2014
Posts: 8

PostPosted: Mon Jun 15, 2015 6:12 pm    Post subject: Reply with quote

Hi Harold,
Yes, I have.
Sorry I posted a wrong log file. Please see below for a proper one.

...
NOTIFY sip:1004@127.0.0.1 SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5054;rport;branch=z9hG4bKd011d912b72
From: sip:1004@127.0.0.1;tag=be4e6e51bp
To: <sip:1004@127.0.0.1>
Max-Forwards: 20
Contact: <sip:127.0.0.1:5054>
Call-ID: 5d6fbe9f-9300df69-1cef1255-35a5d7e7
User-Agent: Brekeke PBX
CSeq: 1 NOTIFY
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: 86

Messages-Waiting: yes
Message-Account: sip:8@192.168.0.3
Voice-Message: 28/0 (0/0)

==============================================
============================================
Rule [PN3_NotifyVoiceMes]
Pattern: $request = ^NOTIFY
Input: $request = NOTIFY sip:1004@127.0.0.1 SIP/2.0
Result: true

Pattern: $getSIPuser(To) = (.+)
Input: $getSIPuser(To) = 1004
%1 <= 1004
Result: true

Pattern: $pn.user("%1") = true
Input: $pn.user("1004") = true
Result: true

Pattern: Content-Type = application/simple-message-summary
Input: Content-Type = application/simple-message-summary
Result: true

Pattern: $body("Messages-Waiting: (.+)") = yes
Input: $body("Messages-Waiting: (.+)") = yes
Result: true

Pattern: $body("Voice-Message: (\d+)/") = (.+)
Input: $body("Voice-Message: (\d+)/") = null

Result: false

Thanks,
Back to top
View user's profile
Harold
Brekeke Master Guru


Joined: 21 Sep 2008
Posts: 287
Location: Japan

PostPosted: Mon Jun 15, 2015 9:57 pm    Post subject: Reply with quote

Try \\d
Since it is within a "", you need to escape \ with one more \.

$body("Voice-Message: (\\d+)/") = (.+)
Back to top
View user's profile
tuctran
Brekeke Junior Member


Joined: 04 Sep 2014
Posts: 8

PostPosted: Tue Jun 16, 2015 4:34 am    Post subject: Reply with quote

Thanks Harold,

It works now.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1