Misc. Dialplan Tools regex

From FreeSWITCH Wiki
Revision as of 02:16, 1 August 2009 by Mcollins (Talk | contribs)

Jump to: navigation, search

Contents

Description

Execute Regular Expression
NOTE: Technically this is not a dialplan application but rather an API. API's are normally done at the CLI, however using the ${my_api(my_args)} syntax with the set application allows for the use of many API's inside the dialplan itself.

Usage

regex value expression results*

( results is opitional, without this argument the regex returns true or false )

you can test your dialplan on the FS console like this

regex 61555555555|^61([0-9]{9})$|0%1 

this would return 0555555555

regex 61555555555|^61([0-9]{9})$

this would return true

Parameters

  • value = string to run regex against
  • expression = the actual regular expression
  • results = result handling string ( optional. without the regex returns true / false )

in your results string, you can not use $0 $1 $2 $3 as you normally would, as they would contain the results of your "condition" expression.

so inline Regex's use %0 %1 %2 %3 as their format.

Examples

modify an Australian E164 caller_id to 0NSN format

<action application="set" data="effective_caller_id_number=${regex(${caller_id_number}|^61([0-9]{9})$|0%1)}"/>

See Also