<br>&nbsp;&nbsp; I really don&#39;t know about perf differences in this case. I guess best thing would be for you do give a try (and let us know please). :) It probably will depend on the java implementation of the matches() against indexOf() method. I guess indexOf is faster, but don&#39;t know if it is significant difference.
<br>&nbsp;&nbsp; Regarding pluggable operators, here you have one example: <br><br><a href="http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java">
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java</a><br><br>&nbsp;&nbsp;&nbsp; Regarding using the descriptor classes, I would say it is the recommended way for generated rules, since you avoid the &quot;text generation&quot;+&quot;parsing&quot; cost of the rules. Although, as much as we try to keep backward compatibility, we can&#39;t guarantee there will be no breaks, since we are always adding new features and the descriptor model must usually change to support them what may eventually break backward compatibility. Even with that, I think it is an affordable cost to pay (fixing eventual breaks on version updates) compared to your runtime application robustness.
<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br>&nbsp;&nbsp;&nbsp; <br><br><div><span class="gmail_quote">2007/12/14, Waruzjan Shahbazian &lt;<a href="mailto:wshahbazian@xiam.nl">wshahbazian@xiam.nl</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>Thanks for the reply. I wanted to be sure that there wasn&#39;t any more<br>efficient way to check a substring in a string, or do you think that<br>eval() with a indexOf() call would be more efficient than matches() with
<br>regular expression?. Since I can&#39;t group the results, the speed is the<br>only issue here.<br><br>In my application I am creating the PackageDescr myself with some<br>&quot;template&quot; RuleDescr&#39;s (which are being filled in with the, limited,
<br>user input in the Swing GUI) and the package is being build with the<br>builder. If the regular expression methode in the matches operator is<br>the best way to check a substring in a string, I can use variabeles<br>(which are the user inputs) to fill the regular expression. So I don&#39;t
<br>really need a new operator for this. But I am interessted how the<br>development of a new operator would be, so maybe you could tell me where<br>I need to be to do so :-) .<br><br>In the attachment&nbsp;&nbsp;is the classe diagram of the PackageDescr with the
<br>linked classes as I have understood and used in my application. Of<br>course not every operation and attribute is included, but maybe this<br>could be helpfull for someone else who wants to create PackageDescr&#39;s<br>
directly.<br><br>I suppose the public methodes used in this operation are going to be<br>supported by the following drools versions? Or should I have used the<br>DRL and XML ? =-O<br><br>Thanks,<br><br>Waruzjan<br><br>Edson Tirelli schreef:
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Yes, you may use matches. The other alternative is using an eval and a<br>&gt; regular indexOf() call to check for the existance of the substring. Drools<br>&gt; up to versions 4.0.x is JSE 1.4 compliant, so you can&#39;t use contains()
<br>&gt; method.&nbsp;&nbsp;In trunk, you may also develop your own operator and plug it into<br>&gt; the engine... although, it is not documented yet, but if you want to try, I<br>&gt; can guide you through. And if you want to contribute docs after that, even
<br>&gt; better. :)<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;It is not possible to capture groups and reuse in the RHS. I&#39;m thinking<br>&gt; about a way to bind variables to arbitrary values in the LHS. If we<br>&gt; implement that, than it would be possible for you to do that, but not
<br>&gt; possible at this moment.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Edson<br>&gt;<br>&gt; 2007/12/14, Waruzjan Shahbazian &lt;<a href="mailto:wshahbazian@xiam.nl">wshahbazian@xiam.nl</a>&gt;:<br>&gt;<br>&gt;&gt; Hi,<br>&gt;&gt;<br>&gt;&gt; I need to check in the LHS of my rule if&nbsp;&nbsp;a given String contains an
<br>&gt;&gt; given substring. What is the best way to do that? I can use regular<br>&gt;&gt; expression with matches, but is that the best (fastest) solution?<br>&gt;&gt; (STRING matches &quot;(?i).*SUBSTRING.*&quot;). And can I use regulare expressions
<br>&gt;&gt; capturing groups and than use the results of the groups in the RHS? If<br>&gt;&gt; not, what is the best methode to do that?<br>&gt;&gt;<br>&gt;&gt; Thanks,<br>&gt;&gt;<br>&gt;&gt; Waruzjan<br>&gt;&gt; _______________________________________________
<br>&gt;&gt; rules-users mailing list<br>&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br>&gt;&gt;<br>&gt;&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------<br>&gt;<br>&gt; _______________________________________________<br>&gt; rules-users mailing list
<br>&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;
<br><br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br><br></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;JBoss Drools Core Development<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>