Dialplan XML/PCRE Question: Examples 3, 4, 5 from wiki, escaped parens?
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@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@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
It looks like they should not be escaped. Can you fix it on the wiki? Sent from my iPhone On Oct 3, 2007, at 6:27 PM, "Michael Collins" <mcollins@fcnetwork.com> wrote:
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@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@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
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
what part? Because the ip example should be. This ^00\(.+\)$ I think should be ^00(.+)$ /b On Oct 4, 2007, at 5:42 AM, Jason Garland wrote:
It looks like they should not be escaped. Can you fix it on the wiki?
Sent from my iPhone
On Oct 3, 2007, at 6:27 PM, "Michael Collins" <mcollins@fcnetwork.com> wrote:
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@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@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
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch- users http://www.freeswitch.org
_______________________________________________ Freeswitch-users mailing list Freeswitch-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch- users http://www.freeswitch.org
what part? Because the ip example should be. This ^00\(.+\)$ I think should be ^00(.+)$
/b
Brian, that's what I was talking about, the one for the destination number that's a series of digits, not a dotted quad IP address. It could be ^00(.+)$ to match absolutely any characters following the leading double-zeroes, or it could be ^00(\d+)$ to match only digits after the leading double-zeroes. I suppose it depends on whether the dialplan is anticipating non-numerics in the destination number. I'll update the wiki with non-escaped parens and I'll make a note of the difference between matching (\d+) and (.+) in the dialplan. -MC
participants (3)
-
Brian West
-
Jason Garland
-
Michael Collins