<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><br></div><div style="white-space:pre;font-size:14px"><span style="white-space:pre-wrap;color:rgb(163,21,21)"><br></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">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,<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></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">https://www.kamailio.org/docs/modules/stable/modules/regex.html</a><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Cheers,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">-- <u></u>
<u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning Westerholt –
</span><span><a href="https://skalatan.de/blog/" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span lang="EN-GB"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-GB">Kamailio services –
</span><span><a href="https://gilawa.com/" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://gilawa.com</span></a></span><span>
<span lang="EN-GB"><u></u><u></u></span></span></p>
<p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></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"><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"><sr-users@lists.kamailio.org></a><br>
<b>Subject:</b> [SR-Users] Caseless regex<u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Hello,<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Is it
possible write more readable regular expression<u></u><u></u></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>) {<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt"><span> ...<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt;line-height:14.25pt"><span>}<u></u><u></u></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"><u></u><u></u></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">On the first
option, I get the error:<u></u><u></u></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<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt">Marat<u></u><u></u></p>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Kamailio (SER) - Users Mailing List
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">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">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Funding: <a href="https://www.paypal.me/dcmierla" target="_blank">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">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>