title: Regular Expression to allow specific special characters
body: <p>I'm currently validating a User Name input and I have to validate that certain special characters are allowed to be inserted into the input.</p>
  
  <p>The White List of characters are: </p>
  
  <p><code>$#+{}:?.,~@"</code> and white spaces</p>
  
  <p>And the Black Listed characters are:</p>
  
  <p><code>^$;\-()&lt;&gt;|='%_</code></p>
  
  <p>The validation should allow any alphanumeric character with one or more special characters and white spaces. It could also work with the black list case either way is fine.</p>
  
  <p>I had this: </p>
  
  <pre><code>public static boolean alphNum(String value) {
      Pattern p = Pattern.compile("^[\\w ]*[^\\W_][\\w ]*$");
      Matcher m = p.matcher(value);
      return m.matches();
  }
  </code></pre>
  
  <p>for only alphanumeric characters and white spaces but now the want that specific list of special characters to be allowed also.</p>
  
  <p>Here are some examples of the types I need to allow:</p>
  
  <ul>
  <li>Name1$</li>
  <li>Name1# Name2</li>
  <li>Name1 Name2</li>
  <li>Name Name2</li>
  <li>Name1 Name...</li>
  </ul>
  
  <p>I've seen a lot of regex validations but none this specific, if anyone could help me out with this I'd really appreciate it.</p>