Search:
     
3CX Phone System for Windows Download the Free Edition

Asterisk func regex

Synopsis:

 Regular Expression: Returns 1 if data matches regular expression.

Description:

 REGEX("<regular expression>" <data>)
 
Is the regular expression tied to the beginning of the string?


Notes


  • *CLI> show function REGEX

Return value

Returns 1 if data matches regular expression.

Example

exten => s,1,Set(foo=${REGEX("[abc0-9]"  b4)})
                         — should return 1.

Bugs


The 1.2.10 parser can easily get confused by special characters in your regexp, such as curly braces or the $ anchor. If you suspect that this is the case, put your special characters in a variable as a workaround (ael1 syntax):
 what=foo;
 dollar=$;
 Verbose(${REGEX("^foo$" foo)}); // 1
 Verbose(${REGEX("^foo$" ${what})}); // 0
 Verbose(${REGEX("^foo${dollar}" ${what})}); // 1

In addition, the comma character will be replaced with a pipe character inside the regular expression as follows:
 Verbose(${REGEX("^[0-9]\{10,15\}$" ${telnum})})
will actually be parsed as:
 Verbose(${REGEX("^[0-9]\{10|15\}$" ${telnum})})
To correct this, escape the comma as follows:
 Verbose(${REGEX("^[0-9]\{10\,15\}$" ${telnum})})


See also


External Links

Unix Regular Expressions



Created by: murf,Last modification on Fri 05 of Nov, 2010 [09:26 UTC] by admin


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

 





Search: