[rules-users] pattern

Edson Tirelli tirelli at post.com
Wed Oct 10 12:18:46 EDT 2007


    Markus,

    Yes, eval code block will pass through DRL compiler into the java
compiler. So you need to write the regexp as it is written in standard java
code.
    Now, this must work:

Item( title matches "^Test\s*" )

   Does not matter what characters title contains. If it is not working, it
is a bug. Can you please submit a JIRA with a test case showing the problem?

   Thanks,
      Edson

2007/10/10, Markus Helbig <mhelbig81 at googlemail.com>:
>
> rule "PatternTest"
>         when
>                 $pli:Item( eval(title.matches("^Test\s*")) )
>         then
>                         #
> end
>
> Having a second look i realize that the DroolsParser should not parse
> the pattern string because it's java code ... and i can't use title
> matches "^Test\s*" because title may have chars like (,\ and so on
> that resolves into a RuntimeException (sth. with Groups not closed in
> RegEx).
>
> Cheers
>
> Markus
>
> 2007/10/10, Edson Tirelli <tirelli at post.com>:
> >
> >    Markus,
> >
> >    Can you please show me your rule?
> >
> >    []s
> >    Edson
> >
> > 2007/10/10, Markus Helbig <mhelbig81 at googlemail.com >:
> > > Hi,
> > >
> > > no same exception when i use "\\s". JDK didn't change when i switched
> > > from 3.x to 4.x
> > >
> > > Cheers
> > >
> > > Markus
> > >
> > > 2007/10/10, DELBART Vincent <delbart.v at mipih.fr>:
> > > > Hi,
> > > >
> > > > I think you have to use "Test\\s+".
> > > >
> > > > I don't think it's a DROOLS problem (maybe jdk).
> > > >
> > > > V.
> > > >
> > > >
> > > > -----Message d'origine-----
> > > > De : rules-users-bounces at lists.jboss.org
> > [mailto:rules-users-bounces at lists.jboss.org] De la part de
> > Markus Helbig
> > > > Envoyé : mercredi 10 octobre 2007 11:12
> > > > À : rules-users at lists.jboss.org
> > > > Objet : [rules-users] pattern
> > > >
> > > > Drools Documentation says:
> > > >
> > > > Matches a field against any valid Java Regular Expression. Typically
> > that regexp is a String, but variables that resolve to a valid regexp
> are
> > also allowed. It is important to note that different from java, if you
> write
> > a String regexp directly on the source file, you don't need to escape
> '\'.
> > Example:
> > > >
> > > > but
> > > >
> > > > "Test\s+" is a valid RegEx (it was valid in Drools 3.x too), but
> now:
> > > >
> > > > SyntaxfehlerRule Compilation error : [Rule name=OnlineStreaming
> Start,
> > agendaGroup=MAIN, salience=100, no-loop=true]
> > com/p7s1/swi/phoenix/n24/Rule_OnlineStreaming_Start_0.java
> > (19:923) :
> > > > Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
> > > >
> > > >
> > > >
> > > > What i'm doing wrong here?
> > > >
> > > > Cheers
> > > >
> > > > Markus
> > > > _______________________________________________
> > > > rules-users mailing list
> > > > rules-users at lists.jboss.org
> > > > https://lists.jboss.org/mailman/listinfo/rules-users
> > > >
> > > > _______________________________________________
> > > > rules-users mailing list
> > > > rules-users at lists.jboss.org
> > > > https://lists.jboss.org/mailman/listinfo/rules-users
> > > >
> > >
> > > _______________________________________________
> > > rules-users mailing list
> > > rules-users at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> >
> >
> >
> > --
> >   Edson Tirelli
> >   Software Engineer - JBoss Rules Core Developer
> >   Office: +55 11 3529-6000
> >   Mobile: +55 11 9287-5646
> >   JBoss, a division of Red Hat @ www.jboss.com
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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/20071010/835a6351/attachment.html 


More information about the rules-users mailing list