2012-12-13 134 views
3

我想在drools部分匹配字符串時使用build關鍵字匹配。如何使用regexp與參數匹配Drools中的字符串?

例如

rule "test" 
when Foo(fooid : id) 
    Bar(barid : id, barid not matches "ID=" + fooid + ", " + name) 
then ... 

它似乎不工作,因爲它抱怨「ID =」+ fooid +「,」+名稱。

但如果我刪除所有的參數,它運行即只留下「ID =」

所以,問題似乎是你如何包括匹配模式的更多參數,你會如何解決這個問題?

謝謝

回答

2

你能在規則檢查之前節省fooid,barid。不知道是否有可能,你可以試試看。

string fooid = Food id // use correct syntax 
string barid = Bar id // use correct syntax 
string checkstring = "ID=" + fooid + "," + name 

rule "test" 
    when 
     barid: String(this not matches "(?i)." + checkstring) 
    then 
     System.out.println(checkstring); 
    end 

注意事項:(我)

- 忽略大小寫

+0

你能解釋一下它是如何工作的滴料? – user

0

規則 「PuneUser_Rule」

no-loop true 
ruleflow-group "EvalLoopcondition" 
when 
    m:HelloProcessModel(userlocation in ("PuneUser"), count < 4) 
then 
    m.setLoopcondition(6);update(m); 

在這裏,我們檢查規則,如果PuneUser並且count小於4,則循環將從co運行直到循環條件,直到6。當你正在檢查的字符串

此規則將只follwed是PuneUser或不

相關問題