[rules-users] Regular Expressions : Collections : matches problem

Edson Tirelli tirelli at post.com
Tue Sep 16 19:41:50 EDT 2008


   Did you tried this?

when
    $regexp : String() from regexpString
    $test : Test( name matches $regexp )
then
    // do something
end

    []s
    Edson

2008/9/16 Gary Napier <gnapier at cis.strath.ac.uk>

> Hi folks,
>
> I have searched the archives and can't quite find the right way to write
> this rule, if it's possible.
>
>
> 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.
>
> so i have a basic test harness here to try :
>
> global  Collection    regexpString
>
> rule "Test"
>  when
>      $TEST : TEST( NAME _*matches*_ regexpString )
>  then
>      System.out.println("working");
> end
>
> --------------
> The Collections is set outside the engine and contains test inputs of [".*
> Smith.*",".*-Jones"], and so would match "Dave Smith" or "Rupert
> Perry-Jones"
>
>
> 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?
> In the worst case can i create my own function that uses an iterator and
> java's own regular expression features to do this? (i'm guessing via an
> Eval)
>
> Any help or creative criticism of the design would be appreciated,
>
> Drools 4.07, java6,  (recovering JESS addict ;-) )
>
> Thanks
> Gary
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080916/6d214bc7/attachment.html 


More information about the rules-users mailing list