title: How to escape all Special Characters from whole string at one go in Java
body: <p>Lucene supports escaping special characters that are part of the query syntax. The current list special characters are</p>
  
  <pre><code>+ - &amp;&amp; || ! ( ) { } [ ] ^ " ~ * ? : \
  </code></pre>
  
  <p>To escape these character use the \ before the character. For example to search for (1+1):2 use the query:</p>
  
  <pre><code>\(1\+1\)\:2
  </code></pre>
  
  <p><strong>My question is how to escape from whole string at one go?</strong> For example <code>myStringToEscape = "ABC^ " ~ * ? :DEF";</code> How to get a <strong>escapedString</strong>.</p>