REGEX("Ausdruck" String)^ (passt auf den
Anfang) und $ (passt auf das Ende) enthalten. Variablen werden
vorher ausgewertet.$ oder geschweifte Klammern, die im
Ausdruck vorkommen, verwirrt werden. Als Workaround definiert man sich z. B.
eine Variable ${dollar} mit dem Inhalt "$" und
verwendet diese statt des $-Zeichens.; prüfen, ob der Ausdruck "[abc][0-9]" auf den String "b3" passt:
exten => 123,1,Set(foo=${REGEX("[abc][0-9]" b3)}) ; gibt 1 zurück
; prüfen, ob ${str} mit 0 endet, Asterisk 1.4:
exten => 123,1,Set(foo=${REGEX("0$" ${str})})
; in Asterisk 1.2 behilft man sich so:
exten => 123,1,Set(foo=${REGEX("0${dollar}" ${str})})————————| 1.2 |————————| 1.4 |————————| 1.6 |————————
-= 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.--- in Asterisk 1.2
+++ in Asterisk 1.4
@@ -4,7 +4,10 @@
REGEX("<regular expression>" <data>)
[Synopsis]
- Regular Expression: Returns 1 if data matches regular expression.
+ Regular Expression
[Description]
- Not available
+ 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.