title: Regex first character not matching
body: <p>I am having some Java Pattern problems. This is my pattern: </p>
  
  <pre><code>"^[\\p{L}\\p{Digit}~._-]+$"
  </code></pre>
  
  <p>It matches any letter of the US-ASCII, numerals, some special characters, basically anything that wouldn't scramble an URL.</p>
  
  <p>What I would like is to find the first letter in a word that does not match this pattern. Basically the user sends a text as an input and I have to validate it  and to throw an exception if I find an illegal character. </p>
  
  <p>I tried negating this pattern, but it wouldn't compile properly. Also <code>find()</code> didn't help out much.</p>
  
  <p>A legal input would be <code>hello</code> while <code>?hello</code> should not be, and my exception should point out that <code>?</code> is not proper.</p>
  
  <p>I would prefer a suggestion using Java's Matcher, Pattern or something using <code>util.regex</code>. Its not a necessity, but checking each character in the string individually is not a solution. </p>
  
  <p>Edit: I came up with a better regex to match unreserved URI characters</p>