title: Unable to use dollar sign ($) in java replace method. It is throwing a runtime exception
body: <p>I am having my replace method using regex as below,</p>
  
  <pre><code>String str1="dog0123456yrhh900man";
  String replacedStr=str1.replaceAll("(man|dog)|[^0-9]","$1");
  </code></pre>
  
  <p>Output: <code>dog0123456900man</code></p>
  
  <p>This works fine in normal main method.</p>
  
  <p>but when I include this same logic in my application code which is running in jboss server and environment as linux i am getting runtime error because of this dollar sign.</p>
  
  <p>I tried below also. Its is affecting the expected output</p>
  
  <pre><code>replacedStr=str1.replaceAll("(man|dog)|[^0-9]","\\$1");
  replacedStr=str1.replaceAll("(man|dog)|[^0-9]","\\\\$1");
  replacedStr=str1.replaceAll("(man|dog)|[^0-9]","\\\\\\$1");
  </code></pre>
  
  <p>excpectedoutput: <code>dog0123456900man</code></p>
  
  <p>actual output: <code>dog0123456$1$1$1$1900man</code></p>
  
  <p>i also tried <code>Matcher.quoteReplacement()</code></p>
  
  <p><code>replacedStr=str1.replaceAll("(man|dog)|[^0-9]",Matcher.quoteReplacement("$1"));</code> It is not working.</p>
  
  <p>Kindly help me with suggestion</p>