Reputation: 5235
I am trying to verify if inbound CLI matchest one of these patterns:
CLI STARTING WITH:
So i wrote the following
exten => s,n,Set(isita=${REGEX("^(+39|0039|3|0[1-9])" ${cli})})
However I am getting this error :
Malformed input REGEX(): Invalid preceding regular expression
What is wrong with my regular expression?
Upvotes: 2
Views: 3422
Reputation: 15257
Answer is correct, but use of REGEXP inside dialplan is not so nice idea. Dialplan itself is regexp, it have form for do regexp based on cli
exten => _s/_39.,n,Noop(do something for cli starting with 39)
So it more asterisk-way use dialplan, not regexp.
Upvotes: 0
Reputation: 5596
You need to escape the +
, use this RegEx instead:
^(\\+39|0039|3|0[1-9])
You can see the error when you Test it on RegExr
Normally in a RegEx (in JavaScript for example, whre is it enclosed in /
), you only need one \
, however when the RegEx is stored in a string (in this case anyway), you need 2 \
.
If you have one \
, the string is trying to create a character based on \+
(like \n
is a newline). You need the second \
to state that the first \
should not be converted.
Upvotes: 4