See below.<br><br><div class="gmail_quote">On 3 January 2012 13:01, Lalitha <span dir="ltr">&lt;<a href="mailto:v.lalithasri@gmail.com">v.lalithasri@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204,204,204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Hi all,<br>
<br>
  I am working on drools. I would like to remove Special characters which<br>
are existed in the data i.e. replacing special characters with null.<br>
Following is the code:<br>
<br>
rule &quot;Wild Character validation&quot;<br>
  when<br>
    c : CustomerInfo(customerName != &quot;&quot;);<br></blockquote><div><br>It is much better to write a condition that selects just the objects you&#39;re really interested here, i.e., the ones containing the characters you want to eliminate, thus:<br>
<br>    c: CustomerInfo( customerName matches &quot;.*[*#].*&quot; )<br> </div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204,204,204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<br>
  then<br>
<br>
   int l = c.length();<br>
   int ch = 0;<br>
   int i = 0;<br>
   for (i = 0; i &lt; l; i++) {<br>
      if (data.charAt(i) != &quot;*&quot;|| data.charAt(i) != &quot;#&quot;){<br>
         continue;<br>
        }<br>
        ch++;<br>
        data.setCharAt(i, &quot;&quot;);<br>
      }<br>
   c.setCustomerName(data);<br>
end<br></blockquote><div><br>I assume that you assume that data is a String, but you haven&#39;t assigned it a value. And even if you do, you cannot modify a String. This is simple Java coding, and I&#39;d say that you should go and study a Java text book.<br>
<br>Here&#39;s the right hand side code I&#39;d use:<br><br>String data = c.getCustomerName().replaceAll( &quot;[*#]&quot;, &quot;&quot; );<br>modify( c ){ setCustomerName( data ) }<br><br>I don&#39;t think you want to replace these characters with &quot;null&quot;. I think you just want to remove them from the string, so that<br>
&quot;foo*bar#baz&quot; becomes &quot;foobarbaz&quot;.<br><br>-W<br><br><br><br><br> </div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204,204,204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<br>
Is there any wrong in this code? If so please help me out. Waiting for your<br>
suggestion .<br>
<br>
Thanks and Regards,<br>
<span class="HOEnZb"><font color="#888888">Lalitha.<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Removing-Special-Characters-tp3628821p3628821.html" target="_blank">http://drools.46999.n3.nabble.com/Removing-Special-Characters-tp3628821p3628821.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
</font></span></blockquote></div><br>