<!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">
    Hello!<br>
    <br>
    &nbsp;&nbsp;&nbsp; Yes, I know about LUA native patterns. Unfortunatelly I can't
    (or don't know how to) do something like:<br>
    \d{4,6} or \d{10,}<br>
    <br>
    <blockquote
      cite="mid:BANLkTikebBSkuaTMNZQ6vpFSwVf=FjusTQ@mail.gmail.com"
      type="cite">I don't believe there is a way to pull multiple values
      back from the call to api:execute. However, Lua has native pattern
      matching with captures. Here are a few resources for you:
      <div><br>
      </div>
      <div>FreeSWITCH book, pages 149-151</div>
      <div><a moz-do-not-send="true"
          href="http://www.lua.org/pil/20.3.html">http://www.lua.org/pil/20.3.html</a></div>
      <div><a moz-do-not-send="true"
          href="http://www.lua.org/manual/5.1/manual.html#5.4.1">http://www.lua.org/manual/5.1/manual.html#5.4.1</a></div>
      <div><br>
      </div>
      <div>Here's a simple example that you can actually run with
        "luarun" if you want to do some testing:</div>
      <div><br>
      </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">data = "1234#5678";</font></div>
      <div><font class="Apple-style-span" face="'courier new',
          monospace">_,_,var1,var2 = string.find(data,"(%d+)#(%d+)");</font></div>
      <div><font class="Apple-style-span" face="'courier new',
          monospace">freeswitch.consoleLog("INFO","\ndata: " .. data ..
          "\nvar1: " .. var1 .. "\nvar2: " .. var2 .. "\n");</font></div>
      <div><br>
      </div>
      <div>Output:</div>
      <div>
        <div><font class="Apple-style-span" face="'courier new',
            monospace">freeswitch@internal&gt; luarun pattern.lua</font></div>
        <div><font class="Apple-style-span" face="'courier new',
            monospace">+OK</font></div>
        <div><font class="Apple-style-span" face="'courier new',
            monospace"><br>
          </font></div>
        <div><font class="Apple-style-span" face="'courier new',
            monospace">2011-04-18 08:28:49.242080 [INFO]
            switch_cpp.cpp:1197&nbsp;</font></div>
        <div><font class="Apple-style-span" face="'courier new',
            monospace">data: 1234#5678</font></div>
        <div><font class="Apple-style-span" face="'courier new',
            monospace">var1: 1234</font></div>
        <div><font class="Apple-style-span" face="'courier new',
            monospace">var2: 5678</font></div>
        <div><br>
        </div>
        <div>Have fun!</div>
        <div>-MC</div>
        <div><br>
        </div>
        <div>P.S. - I added some of this information to the wiki:</div>
        <div><a moz-do-not-send="true"
href="http://wiki.freeswitch.org/wiki/Mod_lua#Native_Lua_Pattern_Matching">http://wiki.freeswitch.org/wiki/Mod_lua#Native_Lua_Pattern_Matching</a></div>
        <br>
        <div class="gmail_quote">On Mon, Apr 18, 2011 at 6:06 AM, Boris
          Kovalenko <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:boris@tagnet.ru">boris@tagnet.ru</a>&gt;</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;">
            Hello!<br>
            <br>
            &nbsp; &nbsp; How can I use regexp with LUA scripts? Yes, I found I
            may use<br>
            api:execute('regex'....) but can't understand how to get
            matched strings<br>
            from it. For example my re is (\d+)#(\d+) and I want to get
            $1 and $2 in<br>
            some variables.<br>
            <br>
            --<br>
            Regards,<br>
            Boris<br>
            <br>
            <br>
            <br>
            _______________________________________________<br>
            FreeSWITCH-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users"
              target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
            UNSUBSCRIBE:<a moz-do-not-send="true"
              href="http://lists.freeswitch.org/mailman/options/freeswitch-users"
              target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
            <a moz-do-not-send="true" href="http://www.freeswitch.org"
              target="_blank">http://www.freeswitch.org</a><br>
          </blockquote>
        </div>
        <br>
      </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">-- 
Regards,
Boris

</pre>
  </body>
</html>