Upgrade 3CX to v18 and get it hosted free!

Asterisk func regex

Author image

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

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.