replace values between two dollar symbol
<p>I need to replace a value between two dollar($) symbol.</p>

<p>below is the way i tried but i dont think it is an elegant way to do.</p>

<pre><code>String queryNoAdditionalFilter= SELECT PRODUCTNAME,PRODUCTSKEY FROM PRODUCTS WHERE PRODUCTID=$productid$

    int start= queryNoAdditionalFilter.indexOf("$");
     int end= queryNoAdditionalFilter.lastIndexOf("$");
     String valueSubstitutedToFilter1 = queryNoAdditionalFilter.substring(start+1, end);
      String keyToReplace = "\\$"+valueSubstitutedToFilter1+"\\$";
     String valueSubstitutedToFilter2=queryNoAdditionalFilter.replaceAll(keyToReplace, "401250");


final outcome is :SELECT PRODUCTNAME,PRODUCTSKEY FROM PRODUCTS WHERE PRODUCTID=401250 
</code></pre>

<p>which is the best way to implement this logic through java code?</p>

<p>Need your advise.</p>
