[rules-users] startsWith function
Mattias Nilsson Grip
mattias.nilsson.grip at redpill-linpro.com
Mon Aug 8 03:42:34 EDT 2011
aftab wrote:
>
> I want to define rules for below function,
>
> private boolean isFixedNumber(Call call){
>
> if(call.getCalledNumber().startsWith("01") ||
> call.getCalledNumber().startsWith("02") ||
> call.getCalledNumber().startsWith("03") ){
> return true;
> }
> else{
> return false;
> }
> }
>
> Give some hints how can i define it ?
> I was trying to define it in below format,
> rule "Is Fixed Number"
> dialect "java"
> when c : CDRRecords
> (calledNumber.startsWith( "011") )
> then
> c.setFixedNetNumber(true);
> System.out.println("c.setFixedNetNumber (true) "); // consequence
>
> end
>
>
> Thanks in advance for your support ...
>
If you're using Drools 5.2 you should be able to do:
c : CDRRecords( calledNumber str[startsWith] "011" )
If you are on earlier version of Drools you can match with a regular
expression:
c : CDRRecords( calledNumber matches "011.*" )
/Mattias
--
View this message in context: http://drools.46999.n3.nabble.com/startsWith-function-tp3228735p3234795.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list