REGEX("Ausdruck" String)Gibt 1 zurück, wenn ein String auf einen regulären Ausdruck passt,
sonst 0. Der reguläre Ausdruck kann auch
^ (passt auf den
Anfang) und $ (passt auf das Ende) enthalten. Variablen werden
vorher ausgewertet.Der Parser in Asterisk 1.2 arbeitet nicht sauber und kann durch
besondere Zeichen wie
$ 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})})Asterisk-Versionen:
————————| 1.2 |————————| 1.4 |————————| 1.6 |————————
Interner Hilfetext zu dieser Funktion 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.Differenz des internen Hilfetexts von Asterisk 1.2 zu 1.4:
--- 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.