title: Why the following regex [^0-9!a-zA-z#\\$%&'\\*\\+\\-/=\\?\\^_`\\{\\|\\}~@\\.]+ for String.split is not working?
body: <p>I have this regular expression:</p>
  
  <pre><code>[^0-9!a-zA-z#\\$%&amp;'\\*\\+\\-/=\\?\\^_`\\{\\|\\}~@\\.]+
  </code></pre>
  
  <p>and I am trying to split the email address using </p>
  
  <pre><code>[Email]info@emerycommunications.com
  </code></pre>
  
  <p>But the following code in java:</p>
  
  <pre><code>String fileStr = "[Email]info@emerycommunications.com";
  
  String invalidCharacters = "[^0-9!a-zA-z#\\$%&amp;'\\*\\+\\-/=\\?\\^_`\\{\\|\\}~@\\.]+";
  
  String[] tokens = fileStr.split(invalidCharacters);
  
  for (String token:tokens) {
      if (token.contains("@")) {
          System.out.println(token);
      }
  }
  </code></pre>
  
  <p>is giving this output:</p>
  
  <pre><code>[Email]info@emerycommunications.com
  </code></pre>
  
  <p>I am completely clueless as <code>invalidCharacters</code> variable covers <code>[</code> and <code>]</code> also.</p>