And what about using a global?<div><br></div><div>Best Regards<br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>

- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">2011/1/24 Bruno Freudensprung <span dir="ltr">&lt;<a href="mailto:bruno.freudensprung@temis.com">bruno.freudensprung@temis.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">




  

<div bgcolor="#ffffff" text="#000000">
<br>
Thanks for the advice!<div><div></div><div class="h5"><br>
<br>
Bruno.<br>
<br>
<br>
Wolfgang Laun a écrit :
<blockquote type="cite">
  <pre>If some value is variable, it must be privided in a fact - otherwise
the Inference Engine does not register any changes.

Notice that you cannot use &quot;matches&quot; in an eval, where plain Java (or
mvel) must be used.

-W

2011/1/24 Bruno Freudensprung <a href="mailto:bruno.freudensprung@temis.com" target="_blank">&lt;bruno.freudensprung@temis.com&gt;</a>:
  </pre>
  <blockquote type="cite">
    <pre>Thanks Wolfgang! My sincere apologies for the wrong answer.
Does it mean that (probably at the price of a performance penalty) one could
handle the variable results of getPropName() over time and write (?):

MyEvent(eval (prop1 matches (&quot;This event is for&quot;+getPropName()+&quot; and is sent
toblah blah blah&quot;)))

Best regards,

Bruno.

Wolfgang Laun a écrit :

2011/1/24 Bruno Freudensprung <a href="mailto:bruno.freudensprung@temis.com" target="_blank">&lt;bruno.freudensprung@temis.com&gt;</a>


MyEvent(prop1 matches eval(&quot;This event is for&quot;+getPropName()+&quot; and is sent
to
blah blah blah&quot;))



You cannot use eval() like this. It is a conditional element.

If getPropName() is a function that is constant over time (!) then you
should be able to

   MyEvent(prop1 matches (&quot;This event is for&quot;+getPropName()+&quot; and is...&quot;))

If you need to match against a value that should change during
execution, put the value into a fact and make sure to update/modify
that fact when you change the value:

   MyPattern( $v: value )
   MyEvent( prop1 matches (&quot;This event is for&quot;+$v +&quot; and is...&quot;))

In both cases, the parentheses around the concatenaion are essential.

-W





Best regards,

Bruno.


Ayush a écrit :

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

MyEvent(prop1 matches &quot;This event is for&quot;+getPropName()+&quot; and is sent to
blah blah blah&quot;)

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
&quot;Expecting &#39;)&#39; instead of &#39;(&#39; &quot;.

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(&quot;This event is for&quot;,getPropName()+&quot;
and is sent to blah blah blah&quot;)

Now when I&#39;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.




_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>



_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>



_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>


    </pre>
  </blockquote>
  <pre>_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>

  </pre>
</blockquote>
<br>
</div></div></div>

<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>