[rules-users] Pattern matching rules
Wolfgang Laun
wolfgang.laun at gmail.com
Wed Jul 24 07:10:48 EDT 2013
I think that OP is looking for a "higher order function operator",
i.e., applying pattern matching to all elements of a list returning
true if there is a match. Cf. Perl's
grep( /Action/, @likes )
It's not too difficult to implement such an operator.
Also, a simple DRL function would do the trick (pseudocode):
boolean function containsMatching( Pattern regex, List list )
for elem in list
if elem =~ regex then return true end
end
return false
end
-W
On 24/07/2013, Mauricio Salatino <salaboy at gmail.com> wrote:
> yeah you can use the matches operator and write your own regular expression
> there.
>
> Cheers
>
>
> On Wed, Jul 24, 2013 at 10:47 AM, rganesh84 <ganesh_r04 at infosys.com> wrote:
>
>> I was just wondering if there is a pattern matcher available in drools.
>> Below is a sample
>>
>> rule "Action Movies"
>> dialect "java"
>> when
>> ui : UserInfo(likes contains "Action")
>> then
>> List sw = new ArrayList();
>> sw.add("Die Hard");
>> sw.add("The Avengers");
>> ui.setRecs(sw);
>> end
>>
>> the rule strictly checks for word "Action" but if the likes list contains
>> "Action Movies" the rule won't get processed. Is there a pattern matching
>> ability or a like search for a String/list containing strings?
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/Pattern-matching-rules-tp4025112.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> --
> - MyJourney @ http://salaboy.com <http://salaboy.wordpress.com>
> - Co-Founder @ http://www.jugargentina.org
> - Co-Founder @ http://www.jbug.com.ar
>
> - Salatino "Salaboy" Mauricio -
>
More information about the rules-users
mailing list