<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>libpcre3 is known to be very fast, not sure you will notice any
      performance impact because of runtime regular expression parsing,
      everything being done in memory and for sure not with simple
      expressions like <span>"(?i)^test$"</span><span>. This happens
        because the parameters can have variables, which are first
        evaluated, then used for matching.<br>
      </span></p>
    <p><span>Anyhow, a variant of the function with static parameter for
        regex can be added easily.</span></p>
    <p><span>On the other hand, you seem to compare with a full value,
        so you can just use string comparison functions:</span></p>
    <p><span>  *
<a class="moz-txt-link-freetext" href="https://www.kamailio.org/docs/modules/stable/modules/textops.html#textops.f.cmp_str">https://www.kamailio.org/docs/modules/stable/modules/textops.html#textops.f.cmp_str</a><br>
      </span></p>
    <p><span>Cheers,<br>
        Daniel<br>
      </span></p>
    <div class="moz-cite-prefix">On 13.10.20 15:22, Marat Gareev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAGBFc1WN4fmcjAEfrD7ZvxvQAPk60eXinw_p4=psdN70fS=bGg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Henning, Daniel,
        <div>thanks for your replies.</div>
        <div><br>
        </div>
        <div>1. I don't want to use a Regex module because it might have
          a performance impact.</div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Matches
          the given string parameter against the regular expression
          pcre_regex, which is compiled in runtime into a PCRE object.<br>
        </blockquote>
        <div> </div>
        <div>2.  I was surprised to find that the operator "=~" is case
          insensitive:</div>
        <div>
          <div style="color:rgb(0,0,0);font-family:"Droid Sans
            Mono",monospace,monospace,"Droid Sans
            Fallback";line-height:19px">
            <div style="white-space:pre;font-size:14px"><span style="color:rgb(0,0,255)">if</span> (regcomp(re, (<span style="color:rgb(0,0,255)">char</span>*) exp->r.param,</div>
            <div style="white-space:pre;font-size:14px">            REG_EXTENDED|REG_NOSUB|REG_ICASE) ){</div>
            <div style="white-space:pre;font-size:14px">    LM_CRIT(<span style="color:rgb(163,21,21)">"bad re \"%s\"\n"</span>, (<span style="color:rgb(0,0,255)">char</span>*) exp->r.param);</div>
            <div style="white-space:pre;font-size:14px">    pkg_free(re);</div>
            <div style="white-space:pre;font-size:14px">    <span style="color:rgb(0,0,255)">return</span> E_BAD_RE;</div>
            <div style="white-space:pre;font-size:14px">}</div>
            <div style="white-space:pre">so that enough for me:</div>
            <div style="white-space:pre;font-size:14px"><span style="white-space:pre-wrap">$tU =~ </span><span style="white-space:pre-wrap;color:rgb(163,21,21)">"^test$"</span>
</div>
            <div style="white-space:pre;font-size:14px"><span style="white-space:pre-wrap;color:rgb(163,21,21)">
</span></div>
            <div style=""><span style="white-space:pre-wrap">Btw, w</span>hat
              if I need case sensitive validation? Should I use the
              Regex module?</div>
            <div style="font-size:14px"><span style="font-size:small"><br>
              </span></div>
            <div style="font-size:14px"><span style="font-size:small">Regards,</span></div>
            <div style="font-size:14px"><span style="font-size:small">Marat</span></div>
          </div>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">вт, 13 окт. 2020 г. в 14:17,
          Daniel-Constantin Mierla <<a
            href="mailto:miconda@gmail.com" moz-do-not-send="true">miconda@gmail.com</a>>:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p>Hello,</p>
            <p>adding some more details to mention that regex operations
              done by the core (the =~ operator) use the libc posix
              regex functions, which do not support extended syntax.
              Also, these operations done by core use the case
              insensitive flag.</p>
            <p>As mentioned by Henning, regex should be an alternative,
              or maybe dialplan if one wants db-storage+caching of those
              regex rules.</p>
            <p>Moreover, if the above are not enough, a kemi embedded
              interpreter (e.g., app_lua, app_python) can be used with
              inline execution in kamailio.cfg routing blocks -- those
              external scripting languages should have many options for
              regex matching.</p>
            <p>Cheers,<br>
              Daniel<br>
            </p>
            <div>On 13.10.20 13:04, Henning Westerholt wrote:<br>
            </div>
            <blockquote type="cite">
              <div>
                <p class="MsoNormal"><span>Hello,</span></p>
                <p class="MsoNormal"><span> </span></p>
                <p class="MsoNormal"><span lang="EN-GB">just an idea,
                    have you already tried this module: <a
                      href="https://www.kamailio.org/docs/modules/stable/modules/regex.html"
                      target="_blank" moz-do-not-send="true">https://www.kamailio.org/docs/modules/stable/modules/regex.html</a></span></p>
                <p class="MsoNormal"><span lang="EN-GB"> </span></p>
                <p class="MsoNormal"><span lang="EN-GB">Cheers,</span></p>
                <p class="MsoNormal"><span lang="EN-GB"> </span></p>
                <p class="MsoNormal"><span lang="EN-GB">Henning</span></p>
                <p class="MsoNormal"><span lang="EN-GB"> </span></p>
                <p class="MsoNormal"><span lang="EN-GB">-- </span></p>
                <p class="MsoNormal"><span lang="EN-GB">Henning
                    Westerholt – </span><span><a
                      href="https://skalatan.de/blog/" target="_blank"
                      moz-do-not-send="true"><span
                        style="color:rgb(5,99,193)" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span
                    lang="EN-GB"></span></p>
                <p class="MsoNormal"><span lang="EN-GB">Kamailio
                    services – </span><span><a
                      href="https://gilawa.com/" target="_blank"
                      moz-do-not-send="true"><span
                        style="color:rgb(5,99,193)" lang="EN-GB">https://gilawa.com</span></a></span><span>
                    <span lang="EN-GB"></span></span></p>
                <p class="MsoNormal"><span lang="EN-GB"> </span></p>
                <div
style="border-right:none;border-bottom:none;border-left:none;border-top:1pt
                  solid rgb(225,225,225);padding:3pt 0cm 0cm">
                  <p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b>
                    sr-users <a
                      href="mailto:sr-users-bounces@lists.kamailio.org"
                      target="_blank" moz-do-not-send="true"><sr-users-bounces@lists.kamailio.org></a>
                    <b>On Behalf Of </b>Marat Gareev<br>
                    <b>Sent:</b> Tuesday, October 13, 2020 10:55 AM<br>
                    <b>To:</b> Kamailio (SER) - Users Mailing List <a
                      href="mailto:sr-users@lists.kamailio.org"
                      target="_blank" moz-do-not-send="true"><sr-users@lists.kamailio.org></a><br>
                    <b>Subject:</b> [SR-Users] Caseless regex</p>
                </div>
                <p class="MsoNormal" style="margin-left:35.4pt"> </p>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">Hello,</p>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt"> </p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt">Is
                      it possible write more readable regular expression</p>
                  </div>
                  <div>
                    <div>
                      <div>
                        <p class="MsoNormal"
                          style="margin-left:35.4pt;line-height:14.25pt"><span>if</span><span>
                            ($tU =~ </span><span>"(?i)^test$"</span><span>)
                            {</span></p>
                      </div>
                      <div>
                        <p class="MsoNormal"
                          style="margin-left:35.4pt;line-height:14.25pt"><span>   
                            ...</span></p>
                      </div>
                      <div>
                        <p class="MsoNormal"
                          style="margin-left:35.4pt;line-height:14.25pt"><span>}</span></p>
                      </div>
                      <div>
                        <p class="MsoNormal"
                          style="margin-left:35.4pt;line-height:14.25pt"><span
style="font-family:Arial,sans-serif;color:black">instead of</span><span>
                          </span><span>"^[tT][eE][sS][tT]$"</span><span>?</span><span
                            style="color:black"></span></p>
                      </div>
                    </div>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt"> </p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt">On
                      the first option, I get the error:</p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt">0(47250)
                      ERROR: <core> [core/rvalue.c:3038]:
                      fix_match_rve(): Bad regular expression</p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt"> </p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt">Regards,</p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt">Marat</p>
                  </div>
                </div>
              </div>
              <br>
              <fieldset></fieldset>
              <pre>_______________________________________________
Kamailio (SER) - Users Mailing List
<a href="mailto:sr-users@lists.kamailio.org" target="_blank" moz-do-not-send="true">sr-users@lists.kamailio.org</a>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
            </blockquote>
            <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Funding: <a href="https://www.paypal.me/dcmierla" target="_blank" moz-do-not-send="true">https://www.paypal.me/dcmierla</a></pre>
          </div>
          _______________________________________________<br>
          Kamailio (SER) - Users Mailing List<br>
          <a href="mailto:sr-users@lists.kamailio.org" target="_blank"
            moz-do-not-send="true">sr-users@lists.kamailio.org</a><br>
          <a
            href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
        </blockquote>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
  </body>
</html>