[rules-users] Problem implementing dynamic regular expression

Ayush ayush.vatsyayan at alcatel-lucent.com
Mon Jan 24 08:42:48 EST 2011


Hi, I'm trying to implement regular expression using matches. The regular
expression is dynamic and retrieved from a java function. In my first
approach I'm tried to call the java function for matches like

MyEvent(prop1 matches "This event is for"+getPropName()+" and is sent to
blah blah blah")

Now when I try to execute the above expression it gives error as illegal
statement (I even tried back-slash to escape it). It also gives error like
"Expecting ')' instead of '(' ".

So I declared a function which takes two string parameters and returns me
the concatenated one.
function String concatenate(String str1, String str2) {
	return str1+str2;
}

$matchStr : String() from concatenate("This event is for",getPropName()+"
and is sent to blah blah blah")

Now when I'm using this variable in my rule it is not getting executed.
Please note that there is no problem in regex because when I put the regex
as string (i.e. without using any function to retreive it) it works fine.

MyEvent(prop1 matches $matchStr)

Can anyone please let me know how can I solve it. Thanks in advance.


-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-dynamic-regular-expression-tp2319706p2319706.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list