title: Regular Expressions with double backslash in java
body: <p>I want to understand the concept of regular expression in below code:</p>
  
  <pre><code>private static final String SQL_INSERT = "INSERT INTO ${table}(${keys}) 
  VALUES(${values})";
  private static final String TABLE_REGEX = "\\$\\{table\\}";
  .
  .
  .
  String query = SQL_INSERT.replaceFirst(TABLE_REGEX, "tableName");
  </code></pre>
  
  <p>The above code is working fine but i would like to understand how. As per my knowledge $ and { symbols should be escaped in java string using backslash but in above string there is no backslash and if I try to add it, it shows error: invalid escape sequence.</p>
  
  <p>Also why the <code>TABLE_REGEX = "\\$\\{table\\}";</code> contains double backslash?</p>