<div dir="ltr"><br>&nbsp;&nbsp; Did you tried this?<br><br>when<br>&nbsp;&nbsp;&nbsp; $regexp : String() from regexpString<br>&nbsp;&nbsp;&nbsp; $test : Test( name matches $regexp )<br>then<br>&nbsp;&nbsp;&nbsp; // do something<br>end<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">
2008/9/16 Gary Napier <span dir="ltr">&lt;<a href="mailto:gnapier@cis.strath.ac.uk">gnapier@cis.strath.ac.uk</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi folks,<br>
<br>
I have searched the archives and can&#39;t quite find the right way to write this rule, if it&#39;s possible.<br>
<br>
<br>
In a nutshell i have a Global Collection of regular expression patterns. I would like a rule to take a single string from a fact and try to match it to any of the saved patterns.<br>
<br>
so i have a basic test harness here to try :<br>
<br>
global &nbsp;Collection &nbsp; &nbsp;regexpString<br>
<br>
rule &quot;Test&quot;<br>
 &nbsp;when<br>
 &nbsp; &nbsp; &nbsp;$TEST : TEST( NAME _*matches*_ regexpString )<br>
 &nbsp;then<br>
 &nbsp; &nbsp; &nbsp;System.out.println(&quot;working&quot;);<br>
end<br>
<br>
--------------<br>
The Collections is set outside the engine and contains test inputs of [&quot;.* Smith.*&quot;,&quot;.*-Jones&quot;], and so would match &quot;Dave Smith&quot; or &quot;Rupert Perry-Jones&quot;<br>
<br>
<br>
Can you help me fix the above code in order to do that. I am new to drools and am struggling to get my head around complexities like accumulates and collect(). Would these help?<br>
In the worst case can i create my own function that uses an iterator and java&#39;s own regular expression features to do this? (i&#39;m guessing via an Eval)<br>
<br>
Any help or creative criticism of the design would be appreciated,<br>
<br>
Drools 4.07, java6, &nbsp;(recovering JESS addict ;-) )<br>
<br>
Thanks<br>
Gary<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>