<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Thank You, Michael! Another way is use more specific LUA patterns.<br>
<blockquote
cite="mid:BANLkTi==pCURntsL4z1Wc6cY+5uOOT+vbQ@mail.gmail.com"
type="cite"><br>
<br>
<div class="gmail_quote">On Thu, Apr 21, 2011 at 10:41 AM, Boris
Kovalenko <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:boris@tagnet.ru">boris@tagnet.ru</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div text="#000000" bgcolor="#ffffff"> No success. I use it
with string.match function, is it right?
<div>
<div class="h5"><br>
</div>
</div>
</div>
</blockquote>
<div>Okay, this is a limitation in Lua's pattern matching.
Evidently you cannot use ? on a group like you can in PCRE. So
in this case you can use an API call to regex. I wrote a mini
test script to demonstrate.</div>
<div><br>
</div>
<div>Have fun. :)</div>
<div>-MC</div>
<div><br>
</div>
<div>
<div><font class="Apple-style-span" face="'courier new',
monospace">--
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">-- pattern.lua
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">--
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">-- Simple Lua pattern testing
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">api = freeswitch.API();
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">str_pattern = "(3435)230%d%d%d";
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">my_str = "73435230111"
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">str_regex = "^(7?3435)?230\\d\\d\\d$";
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">res = api:execute("regex",my_str .. "|" ..
str_regex);
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">stream:write("string: " .. my_str .. ", regex
result: " .. res .. "\n");
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">my_str = "3435230111";
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">res = api:execute("regex",my_str .. "|" ..
str_regex);
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">stream:write("string: " .. my_str .. ", regex
result: " .. res .. "\n");
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">my_str = "230111";
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">res = api:execute("regex",my_str .. "|" ..
str_regex);
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">stream:write("string: " .. my_str .. ", regex
result: " .. res .. "\n");
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">my_str = "987230111";
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">res = api:execute("regex",my_str .. "|" ..
str_regex);
</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">stream:write("string: " .. my_str .. ", regex
result: " .. res .. "\n");
</font></div>
<div>
</div>
<div>Output:</div>
</div>
<div>
<div><font class="Apple-style-span" face="'courier new',
monospace">freeswitch@internal> lua pattern.lua</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">string: 73435230111, regex result: true</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">string: 3435230111, regex result: true</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">string: 230111, regex result: true</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">string: 987230111, regex result: false</font></div>
<div><br>
</div>
</div>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
FreeSWITCH-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
С уважением,
Борис Коваленко
ЗАО "Тагнет"
тел. +7 (3435) 230001
факс +7 (3435) 230005
</pre>
</body>
</html>