[asterisk-users] escaping regular expression

Klaus Darilion klaus.mailinglists at pernau.at
Wed Feb 4 06:17:23 CST 2009


Hi!

I am going nuts using REGEXP. I just want to verify if a variable 
contains a valid +E164 phone number.

These, the the pattern is ^\+[0-9]+

First I tried:

   Set(pattern=^\+[0-9]+);
   if (${REGEX("${pattern}" ${${var}})})

but that does not work, the backslash is removed, as seen in the log file:

   func_strings.c: FUNCTION REGEX (^+[0-9]+)(+4312345 
<http://www.adaanumber.com/>)

So, meanwhile I tried to escape the backslash. I tried:
   Set(pattern=^\\+[0-9]+);
   Set(pattern=^\\\+[0-9]+);
   Set(pattern=^\\\\+[0-9]+);

But always the same result:

   func_strings.c: FUNCTION REGEX (^+[0-9]+)(+4312345)

How can I solve this problem?

Thanks
Klaus



More information about the asterisk-users mailing list