<div><br></div><div>    Try:</div><div><br></div>when<div>    TestClass( $list : listOfStrings )<br><div>    Number( $count : intValue ) from accumulate(</div><div>           String( this matches &quot;^a.b.*$&quot; ) from $list,</div>
<div>           count(1) )</div><div>then</div><div>    // $count has number of matching strings</div><div>end</div><div><br></div><div>    []s</div><div>    Edson</div><div><br></div><div><br><div class="gmail_quote">2010/7/31 ceemh3 <span dir="ltr">&lt;<a href="mailto:martin_henderson@hotmail.com">martin_henderson@hotmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
<br>
does anybody know if there is a way to do for loops in drools ?.<br>
<br>
I am trying to loop through a list of string to see if one of the strings<br>
matches a pattern e.g.<br>
<br>
def listOfStrings = [&#39;a&#39;,&#39;a.b&#39;,&#39;a.b.c&#39;]<br>
<br>
for(String s:listOfStrings){<br>
 if(s matches &quot;^a.b.*$&quot;){<br>
 return true<br>
 }<br>
}<br>
<br>
I have written the following rule based on what documentation I could find,<br>
but I dont think the syntax is correct<br>
<br>
rule &quot;Matcher&quot;<br>
   when<br>
      TestClass : TestClass(($s matches &quot;^a.b.*$&quot;) from listOfStrings,<br>
count($s))<br>
   then<br>
      TestClass.setResponse( &quot;Condition is True !!&quot; );<br>
end<br>
<br>
I am finding it hard to find good documentation on the drl language<br>
<br>
I would appreciate any help that anybody can give me<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/are-for-loops-possible-in-drools-tp1011729p1011729.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/are-for-loops-possible-in-drools-tp1011729p1011729.html</a><br>

Sent from the Drools - User mailing list archive at Nabble.com.<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div></div>