Regular Expressions (Regex)
You can configure SIP header manipulation rules using regular expressions (regex). Regex is a special text string pattern matching engine which is used to define the condition that must exist in order to use a specific manipulation rule. If the SIP header matches the regex pattern, then the "action" of the manipulation rule is applied to the SIP message. Executing a regex pattern also creates sub-expressions. The sub-expressions are referenced using the $n syntax, where n is a digit in the range of 1 to 13 (e.g., $3). Expressions enclosed by parenthesis (…) are stored in the variables $1, $2 … $n.
Note that spaces within a regular expression must be enclosed by parenthesis, as shown in the first example below:
body.sdp regex (AVP 8)
body.sdp regex avp
This feature provides the following main benefits:
|
■
|
The device does not need to know the SIP header name or structure. |
|
■
|
The sub-expressions can be used in the manipulation action. All that is required is to set the action (for example, add, modify, etc.) and then reference the sub-expression you want to use as the value. |
Regex is supported in the following tables and corresponding fields:
Configuration Tables and Relevant Fields
|
|
Message Manipulations Table
|
|
Message Conditions Table
|
|
Pre-Parsing Manipulation Table
|
|
Call Setup Rules Table
|
|
Syntax:
<$n>
Where <$n> is used to reference a resulting sub-expression after executing a regex in a condition; where n is an integer referencing the sub-expression.
|
●
|
The regex pattern ".*" for multi-line match is supported. |
|
●
|
To concatenate, use the + operator, e.g., $1 + ‘some text’ + $3 |
|
●
|
Rand function can be used in the 'Replace-With' field (as a sub-value), for example, $1 + rand.number.1.10. |
|
●
|
Double backslash \\ can be used to state a new line (in 'Replace-With' field), for example, to replace a pattern with multi-line text. |