title: How to escape certain characters in java
body: <p>I need to escape characters like <code>^</code>, <code>.</code>, <code>[</code>, <code>]</code>, <code>+</code> and <code>\</code> (tabs and newlines won't be an issue), while leaving others like <code>*</code> and <code>?</code>.</p>
  
  <p>EDIT = More specifically, I have a string with these characters, and I need to escape them so that they are not matched by regular expressions. I need to prepend <code>\</code> to each of these characters, but doing so individually would take 7 or 8 scans and I'd like to do it within just one pass (IE: anything that matches is prepended with <code>\</code>)</p>
  
  <p>How do I do this?</p>
  
  <p>Thanks.</p>