Skip to main content

mod_dptools: capture

About

Capture digits into a channel variable array.

Examples

Here are some raw examples you can put into a dialplan to get an idea of what happens with arrays:

 <extension name="arrays">
<condition field="destination_number" expression="^110(\d*)$">
<action application="set" data="barfoo=testing"/>
<action application="log" data="ERR barfoo=[${barfoo}]"/>
<action application="log" data="ERR barfoo[100]=[${barfoo[100]}]"/>
<action application="set" data="barfoo[100]=yipee"/>
<action application="log" data="ERR barfoo=[${barfoo}]"/>
<action application="push" data="foobar,test A"/>
<action application="push" data="foobar,test B"/>
<action application="push" data="foobar,test C"/>
<action application="unshift" data="foobar,test M"/>
<action application="set" data="foobar[1]=w00t"/>
<action application="set" data="foobar[100]=doh"/>

<action application="log" data="ERR foobar[1]=[${foobar[1]}]"/>
<action application="log" data="ERR foobar[100]=[${foobar[100]}]"/>
<action application="log" data="ERR foobar=[${foobar}]"/>

<action application="set" data="foobar=plain"/>
<action application="log" data="ERR foobar=[${foobar}]"/>

<action application="set" data="foobar=ARRAY::hip|:hip|:hooray"/>
<action application="log" data="ERR foobar= [${foobar[0]}] [${foobar[1]}] [${foobar[2]}]"/>


<action application="log" data="ERR DP_MATCH=[${DP_MATCH}]"/>
<action application="log" data="ERR DP_MATCH[1]=[${DP_MATCH[1]}]"/>

<action application="set" data="parseme=2121231234"/>
<action application="capture" data="woot|${parseme}|(\d{3})(\d{3})(\d{4})"/>
<action application="log" data="ERR woot=[${woot}] parts=[${woot[1]}] [${woot[2]}] [${woot[3]}]"/>

<action application="set" data="parseme="/>
<action application="log" data="ERR test=[${parseme}]"/>

</condition>
</extension>