[Freeswitch-users] Dialplan XML/PCRE Question: Examples 3, 4, 5 from wiki, escaped parens?
Michael Collins
mcollins at fcnetwork.com
Wed Oct 3 15:27:22 PDT 2007
Guys,
Quick question. On the wiki I noticed that examples 3, 4, and 5 all use
escaped parentheses, whereas examples 1 and 2 do not.
Example 3:
<extension name="Test3">
<condition field="destination_number" expression="^00\(.+\)$">
<action application="bridge"
data="sofia/profilename/$1 at 192.168.2.2"/>
</condition>
</extension>
Example 2:
<extension name="Test2">
<condition field="network_addr" expression="^192\.168\.1\.1$"/>
<condition field="destination_number" expression="^1(\d+)$">
<action application="bridge"
data="sofia/profilename/$0 at 192.168.2.2"/>
</condition>
</extension>
(Note the expressions following the 'destination_number' fields.)
Is this a typo? I just want to be sure that I am reading this
correctly. Seeing escaped parens in a PCRE tells me that the expression
is attempting to match literal paren characters. Additionally, using
".+" might not be correct here, either. It means, "match one or more of
any character, maximal." If I'm reading the author's intentions
correctly, in example 3 he wants to capture the digits after the 00, so
in the case of "00123456789" he wants $1 populated with "123456789".
Correct me if I'm wrong, but shouldn't the condition and expression look
like this?
<condition field="destination_number" expression="^00(\d+)$">
Here the expression is saying, "Match a string of all digits beginning
with two zeroes; capture the digits following the two zeroes and store
them in $1."
I didn't want to change the documentation without a second opinion.
(FYI, I can't test it right now b/c I don't have a running FS system at
the moment...)
Thanks,
MC
More information about the FreeSWITCH-users
mailing list