Java 如何使用带有参数的regexp匹配Drools中的字符串?

Java 如何使用带有参数的regexp匹配Drools中的字符串?,java,regex,drools,rules,Java,Regex,Drools,Rules,我想在drools的when部分使用in-build关键字matches来匹配字符串 e、 g 它似乎不起作用,因为它在抱怨“ID=“+fooid+”,“+name” 但是如果我删除所有参数,它就会运行,即只留下“ID=” 所以问题似乎在于如何在匹配模式中包含更多参数,如何解决这个问题 谢谢在检查规则之前,您能保存fooid和barid吗。不确定是否可能,你可以试一试 string fooid = Food id // use correct syntax string barid = Bar

我想在drools的when部分使用in-build关键字matches来匹配字符串

e、 g

它似乎不起作用,因为它在抱怨“ID=“+fooid+”,“+name”

但是如果我删除所有参数,它就会运行,即只留下“ID=”

所以问题似乎在于如何在匹配模式中包含更多参数,如何解决这个问题


谢谢

在检查规则之前,您能保存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  
注意事项:

(?i)-忽略案例

规则“普纳规则”

无循环为真
规则流组“EvalLoopcondition”
什么时候
m:HelloProcessModel(用户位置在(“PuneUser”),计数<4)
然后
m、 设置循环条件(6);更新(m);
结束

这里我们检查规则,如果PuneUser和count小于4,则循环将从count运行到loopcondition,即直到6

只有在检查字符串是否为PuneUser时,才会遵循此规则

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