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

abing19881226 q.hong at strath.ac.uk
Mon Aug 27 11:50:53 EDT 2012


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.


More information about the rules-users mailing list