title: java regex for alpha and spaces is including [ ] \
body: <p>This is my regex for my JTextField to not be longer than x characters and to not include anything other than letters or spaces.  <strong>For some reason it is allowing [ ] and \ characters.</strong>  This is driving me crazy.  Is my regex wrong??</p>
  
  <pre><code>package com.jayavon.game.helper;
  
  import java.awt.Toolkit;
  
  import javax.swing.text.AttributeSet;
  import javax.swing.text.BadLocationException;
  import javax.swing.text.PlainDocument;
  
  public class CharacterNameCreationDocument extends PlainDocument {
      private static final long serialVersionUID = 1L;
      private int limit;
  
      public CharacterNameCreationDocument(int limit) {
          super();
          this.limit = limit;
      }
  
      public void insertString(int offset, String  str, AttributeSet attr) throws BadLocationException {
          if (str == null || (getLength() + str.length()) &gt; limit || !str.matches("[a-zA-z\\s]*")){
              Toolkit.getDefaultToolkit().beep();
              return;
          } else {
              super.insertString(offset, str, attr);
          }
      }
  }
  </code></pre>