Regex Basic Examples
The following table provides configuration examples for using regular expressions in the Message Manipulations table.
Regex Examples for Message Manipulation, Message Conditions and CSR
Message Type |
Condition |
Action Subject |
Action Type |
Action Value |
---|---|---|---|---|
invite.request |
header.diversion.0 regex (<.*)(;urlparam= |
header. |
Modify |
$1+$3 |
invite.request |
header.diversion.0 regex (<.*)(;urlparam= |
header. |
Add |
$1 + ';mynewparam=good' + $3 |
invite.response.100 |
header.via regex (SIP/2.0/UDP)(.*); |
header. |
Add |
$3 |
subscribe |
header.to regex (.*)(1001)(.*)@(.*)> |
header.to |
Modify |
$1+$3+'8@'+$4 |
Regex Examples for Pre-Parsing Manipulation Rules
Message Type |
Pattern |
Replace-With |
Explanation |
---|---|---|---|
invite.request |
From: *<sip:([^@]+)(@\S*) |
‘From: <sip:’ + ‘1000’ + $2 |
Replaces user part (if exists) in From header URL with 1000, for INVITE only. |
invite.request |
(From: *<sip:)([^@]+)(@\S*) |
$1 + ‘1000’ + $3 |
Same as above. |
any.response |
Refer-To: *(sip:\S*) |
‘Refer-To: <’ + $1 + ‘>’ |
Encloses Refer-To header value with angled brackets <…>, for responses only. |
|
From: *([^"\r\n]*) (<sip:\S*) |
‘From: “’ + $1 + ‘” ’ + $2 |
Adds quotes to the From header's display name (if exists). |
cancel.request |
(CANCEL sip:)(\d*)(@)(.*)(To: <sip:)(\d*)(@)(.*) |
$1+$6+$3+$4+$5+$6+$7+$8 |
Replaces the user part of the Request-Uri header URL with user part of the To header URL, for SIP CANCEL messages only. |