title: Regular expression special characters not working at the starting of the string in java
body: <p>After trying other variations, I use this regular expression in Java to validate a password:</p>
  
  <pre><code>PatternCompiler compiler = new Perl5Compiler();
  PatternMatcher matcher = new Perl5Matcher();
  pattern = compiler.compile("^(?=.*?[a-zA-Z])(?![\\\\\\\\_\-])(?=.*?[0-9])([A-Za-z0-9-/-~]
  [^\\\\\\\\_\-]*)$");
  </code></pre>
  
  <p>But it still doesn't match my test cases as expected:</p>
  
  <p><code>Apr@2017</code>    match<br>
  <code>$$Apr@2017</code>  no match, but it should match<br>
  <code>!!Apr@2017</code>  no match, but it should match<br>
  <code>!#ap#2017</code>   no match, but it should match<br>
  <code>-Apr@2017</code>   it should not match<br>
  <code>_Apr@2017</code>   it should not match<br>
  <code>\Apr@2017</code>   it should not match</p>
  
  <p>Except three special characters <code>-</code> <code>_</code> <code>\</code> remaining, all should match at the start of the string.</p>
  
  <p><strong>Rules:</strong></p>
  
  <ul>
  <li><p>It should accept all special characters any number of times except above three symbols.</p></li>
  <li><p>It must and should contain one number and Capital letter at any place in the string.</p></li>
  </ul>