[rules-users] Extracting data from strings(regular expression)

Wolfgang Laun wolfgang.laun at gmail.com
Mon Aug 27 12:26:11 EDT 2012


Although there is the "matches" operator, Drools isn't a sophisticated
regular expression engine.

Once you have matched a fact with a String line that matches some
regular expression, you'll have to reapply the regular expression on
the right hand side so that you can extract the string matching group
1. Or use simple String methods to extract this information, now that
you know that the string has a certain pattern.

-W




On 27/08/2012, abing19881226 <q.hong at strath.ac.uk> wrote:
> Hi:
> I am trying to match a string to my regular expression and then capture
> certain groups from the string.
> I know previously there is no such feature , but I am just wondering if
> there is one now?
>
> Basically , what am trying to do is,  insert strings into the session, and
> carry out the reasoning to see if matches a certain regular expression.
> In JAVA I did it as this:
>
>
>        public double parsingZ4_Ph_Reach(String line){
>                      String regx="3240, Z4 Ph. Reach, .*, (.*), ohm, .*,
> .*,
> .*";
>                      Pattern
> p=Pattern.compile(regx,Pattern.CASE_INSENSITIVE);
>                      Matcher m =p.matcher(line);
>                      if(m.matches()){
>                            return Double.parseDouble(m.group(1));
>                      }
>                      return 0;
>               }
>
>
> The purpose is to extract the data in the strings using drools.
> Could you please give me some idea I I could do that in Drools?
> Many thx.
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Extracting-data-from-strings-regular-expression-tp4019405.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
>


More information about the rules-users mailing list