how do i replace any string with a "$ " in java?
<p>Using <code>replaceAll()</code> is giving me a rexex exception.</p>

<p>This is the code I am using:</p>

<pre><code>public class test {

    public static void main(String[] args) {
        String text= "This is to be replaced &amp;1 ";
        text = text.replaceAll("&amp;1", "&amp;");
        System.out.println(text);   
    }
}
</code></pre>

<p>EXCEPTION:</p>

<pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Illegal group reference
    at java.util.regex.Matcher.appendReplacement(Unknown Source)
    at java.util.regex.Matcher.replaceAll(Unknown Source)
    at java.lang.String.replaceAll(Unknown Source)
    at test.main(test.java:7)
</code></pre>
