if both field and expression are not present in the <condition> tag.  It is instantly evaluated as true without performing the regex.  Therefore there is no expansion and the $1 will remain $1.

Notice all you examples that do not work are missing the field=

e.g.
<condition "${sip_referred_by_user}" expression="4473451">


On Thu, Jul 17, 2008 at 4:08 AM, Matt Darnell <mattdarnell@gmail.com> wrote:
On Wed, Jul 16, 2008 at 10:59 PM, Matt Darnell <mattdarnell@gmail.com> wrote:
>> I would like the dial plan to route based on the number in the
>> Refered-By or Diversion field.
>
>    <extension name="Mailbox_4473451">
>      <condition "${sip_referred_by_user}" expression="4473451">
>        <action application="info"/>
>        <action application="export" data="sip_h_Diversion=3451"/>
>        <action application="bridge"
> data="{absolute_codec_string=PCMA}sofia/gateway/gw.akamaitel.com/3451"/>
>      </condition>
>    </extension>
>
>    <extension name="Mailbox_4473452">
>      <condition "${sip_referred_by_user}" expression="4473452">
>        <action application="info"/>
>        <action application="export" data="sip_h_Diversion=3452"/>
>        <action application="bridge"
> data="{absolute_codec_string=PCMA}sofia/gateway/gw.akamaitel.com/3452"/>
>      </condition>
>    </extension>
>
> For some reason, all calls go to the first extension.  When I look at
> the out put from info, the sip_referred_by_user is 4473452 but it
> still routes to the first extension.
> variable_sip_referred_by_user: [4473452]
>
> I have even changed the condition statement of the first extensin to :
> <condition "${sip_referred_BOGUS_by_user}" expression="4473451">
> and it still executes that extension.
>
> Please let me know if you can see the issue.
>
> -Matt
>

Another interesting thing is that if I have this:
   <extension name="Mailbox_4473451">
     <condition "${sip_referred_by_user}" expression="^\d{3}(\d{4})$">
       <action application="info"/>
       <action application="export" data="sip_h_Diversion=$1"/>
       <action application="bridge"
data="{absolute_codec_string=PCMA}sofia/gateway/gw.akamaitel.com/$1"/>
     </condition>
   </extension>

$1 does not get populated with \d{4}, the invite has $1 in the string.

This however works fine:
<condition field="destination_number" expression="^\d{3}(\d{4})$">



--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale@hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org
pstn:213-799-1400