Hi,
I have written a rule below which will be triggered when it finds an email id in the text, but when I am executing this getting the below error which is due to the method call matcher.end().
Drools is finding it as end keyword and throwing the exception
Please suggest me on rectifying this
: Error while creating KieBase[Message [id=1, level=ERROR, path=../../../emailaddress.drl, line=22, column=0
text=[ERR 107] Line 22:95 mismatched input '(' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.], Message [id=2, level=ERROR, path=../../../emailaddress.drl, line=0, column=0
text=Parser returned a null Package]]
RULE:
rule "emailaddress rules"
dialect "java"
when
$emailAddress :String(this matches "^.*[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,}).*$")
then
System.out.println("Rule 1-Triggered");
Pattern pattern=Pattern.compile("[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})");
Matcher matcher=pattern.matcher($emailAddress);
while(matcher.find()){
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.");
System.out.println("Email address is:"+$emailAddress.substring(matcher.start(),matcher.end()));
}
System.out.println("Rule Executed successfully");
end