<div class="gmail_quote">2009/2/4 Klaus Darilion <span dir="ltr"><<a href="mailto:klaus.mailinglists@pernau.at">klaus.mailinglists@pernau.at</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
D Tucny schrieb:<br>
<div class="Ih2E3d">> 2009/2/4 Klaus Darilion <<a href="mailto:klaus.mailinglists@pernau.at">klaus.mailinglists@pernau.at</a><br>
</div>> <mailto:<a href="mailto:klaus.mailinglists@pernau.at">klaus.mailinglists@pernau.at</a>>><br>
<div><div></div><div class="Wj3C7c">><br>
> Hi!<br>
><br>
> I am going nuts using REGEXP. I just want to verify if a variable<br>
> contains a valid +E164 phone number.<br>
><br>
> These, the the pattern is ^\+[0-9]+<br>
><br>
> First I tried:<br>
><br>
> Set(pattern=^\+[0-9]+);<br>
> if (${REGEX("${pattern}" ${${var}})})<br>
><br>
> but that does not work, the backslash is removed, as seen in the log<br>
> file:<br>
><br>
> func_strings.c: FUNCTION REGEX (^+[0-9]+)(+4312345<br>
> <<a href="http://www.adaanumber.com/" target="_blank">http://www.adaanumber.com/</a>>)<br>
><br>
> So, meanwhile I tried to escape the backslash. I tried:<br>
> Set(pattern=^\\+[0-9]+);<br>
> Set(pattern=^\\\+[0-9]+);<br>
> Set(pattern=^\\\\+[0-9]+);<br>
><br>
> But always the same result:<br>
><br>
> func_strings.c: FUNCTION REGEX (^+[0-9]+)(+4312345)<br>
><br>
> How can I solve this problem?<br>
><br>
><br>
> Try something like... pattern=^[+]\{1\}[0-9]+<br>
<br>
</div></div>Are you sure? The \ should be in front of the +<br>
<div><div></div><div class="Wj3C7c"><br></div></div></blockquote><div><br>Pretty sure...<br><br>exten => *56,1,NoOp("Starting regexp test")<br>exten => *56,n,Set(pattern=^[+]\{1\}[0-9]+)<br>exten => *56,n,Set(var=123456789)<br>
exten => *56,n,NoOp(${IF(${REGEX("${pattern}" ${var})}?"Match":"No Match")}))<br>exten => *56,n,Set(var=+123456789)<br>exten => *56,n,NoOp(${IF(${REGEX("${pattern}" ${var})}?"Match":"No Match")}))<br>
<br><br>[Feb 4 23:49:21] DEBUG[20518] pbx.c: Launching 'NoOp'<br>[Feb 4 23:49:21] VERBOSE[20518] logger.c: -- Executing [*56@phonedefault:1] NoOp("SIP/*01-09bd8ff8", ""Starting regexp test"") in new stack<br>
[Feb 4 23:49:21] DEBUG[20518] pbx.c: Launching 'Set'<br>[Feb 4 23:49:21] VERBOSE[20518] logger.c: -- Executing [*56@phonedefault:2] Set("SIP/*01-09bd8ff8", "pattern=^[+]\{1\}[0-9]+") in new stack<br>
[Feb 4 23:49:21] DEBUG[20518] pbx.c: Launching 'Set'<br>[Feb 4 23:49:21] VERBOSE[20518] logger.c: -- Executing [*56@phonedefault:3] Set("SIP/*01-09bd8ff8", "var=123456789") in new stack<br>
[Feb 4 23:49:21] DEBUG[20518] func_strings.c: FUNCTION REGEX (^[+]{1}[0-9]+)(123456789)<br>[Feb 4 23:49:21] DEBUG[20518] pbx.c: Function result is '0'<br>[Feb 4 23:49:21] DEBUG[20518] pbx.c: Function result is '"No Match"'<br>
[Feb 4 23:49:21] DEBUG[20518] pbx.c: Launching 'NoOp'<br>[Feb 4 23:49:21] VERBOSE[20518] logger.c: -- Executing [*56@phonedefault:4] NoOp("SIP/*01-09bd8ff8", ""No Match")") in new stack<br>
[Feb 4 23:49:21] DEBUG[20518] pbx.c: Launching 'Set'<br>[Feb 4 23:49:21] VERBOSE[20518] logger.c: -- Executing [*56@phonedefault:5] Set("SIP/*01-09bd8ff8", "var=+123456789") in new stack<br>
[Feb 4 23:49:21] DEBUG[20518] func_strings.c: FUNCTION REGEX (^[+]{1}[0-9]+)(+123456789)<br>[Feb 4 23:49:21] DEBUG[20518] pbx.c: Function result is '1'<br>[Feb 4 23:49:21] DEBUG[20518] pbx.c: Function result is 'Match'<br>
[Feb 4 23:49:21] DEBUG[20518] pbx.c: Launching 'NoOp'<br>[Feb 4 23:49:21] VERBOSE[20518] logger.c: -- Executing [*56@phonedefault:6] NoOp("SIP/*01-09bd8ff8", "Match)") in new stack<br><br>
So, the \ is still stripped (ast_app_separate_args removes \), but, it doesn't matter as the + is bracketed so it's not the first character after the ^ and so regcomp doesn't fail...<br><br>d<br></div></div>