[rules-users] string replace collision problem

FrankVhh frank.vanhoenshoven at agserv.eu
Fri Nov 18 10:20:45 EST 2011


Cautionç This is answered after only a quick look.

You must notify the engie that a change has occured by calling update(plan);
in the RHS. Not calling update will modify the object, but the engine will
not take these changes into account.

Regards,
Frank


fiitkar wrote:
> 
> Hello,
> 
> I've problem with string replacement. 
> See the following example.
> Input string: SF
> I've written two simple rules:
> The first one transforms SF to S
> The second one transforms S to VOL.
> The expected output after the transformation should be  S, but I get VOL.
> (as for example for the rules: A->Z, Z->K,  input A, output will be Z and
> not K).
> So my question is how to avoid this problem (I suppose the problem is that
> the first transformation returns substring of the input and moreover does
> exist another transformation rule for it).
> 
> rule "Rule1 for parameter 1"
> salience 2
> when
> 	plan : plan( parameter1 matches ".*SF.*" )
> then		
> 	plan.setParameter1(plan.getParameter1().replace("SF","S"));
> 	
> end
> 
> 
> rule "Rule2 for parameter 1"
> salience 1
> when
> 	plan : plan( parameter1 matches ".*S.*" )
> then	
> 	plan.setParameter1(plan.getParameter1().replace("S","VOL"));	
> end
> 
> Thank you for your response.
> Peter
> 


--
View this message in context: http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518826p3518860.html
Sent from the Drools: User forum mailing list archive at Nabble.com.




More information about the rules-users mailing list