title: Why does this Java regex cause "illegal escape character" errors?
body: <p>I'm working on a <a href="https://stackoverflow.com/questions/1378978/using-the-netbeans-gui-editor-how-can-i-create-a-jtextfield-or-jformattedtext-fi">solution to a previous question</a>, as best as I can, using regular expressions. My pattern is </p>
  
  <pre><code>"\d{4}\w{3}(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]){2}"
  </code></pre>
  
  <p>According to NetBeans, I have two illegal escape characters. I'm guessing it has to do with the \d and \w, but those are both valid in Java. Perhaps my syntax for a Java regular expression is off...</p>
  
  <p>The entire line of code that is involved is:</p>
  
  <pre><code>userTimestampField = new FormattedTextField(
    new RegexFormatter(
      "\d{4}\w{3}(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]){2}"
  ));
  </code></pre>