C.43. REGEX()

REGEX("expression" string)
Returns 1, if string matches the regular expression expression, otherwise returns 0. The regular expression may include ^ (matches the beginning) and $ (matches the end). Variables are evaluated first.
The parser in Asterisk 1.2 does not behave consistently and can be confused by expressions containing special characters such as $ or angle brackets. An ugly workaround is to define a variable (for example ${dollar}) and have it contain the special character (for example, "$").
; Test to see if the string "b3" matches the regular expression "[abc][0-9]":
exten => 123,1,Set(foo=${REGEX("[abc][0-9]" b3)})   ; returns 1

; Test to see if ${str} ends in 0, for Asterisk 1.4:
exten => 123,1,Set(foo=${REGEX("0$" ${str})})

; in Asterisk 1.2, using the workaround described above:
exten => 123,1,Set(foo=${REGEX("0${dollar}" ${str})})

Note

Internal help for this application in Asterisk 1.4:
  -= Info about function 'REGEX' =- 

[Syntax]
REGEX("<regular expression>" <data>)

[Synopsis]
Regular Expression

[Description]
Returns 1 if data matches regular expression, or 0 otherwise.
Please note that the space following the double quotes separating the regex from the data
is optional and if present, is skipped. If a space is desired at the beginning of the data,
then put two spaces there; the second will not be skipped.
diff output to internal help in Asterisk 1.2:
-- not available in Version 1.2 --