title: Regex to check only capital letters, two special characters (& and Ñ) & without any space between
body: <p>I am using below code snippet to validate my input string with: only capital letters, numbers and two special characters (those are &amp; and Ñ) &amp; without any space between.</p>
  
  <pre><code>var validpattern = new RegExp('[^A-Z0-9\d&amp;Ñ]');
  if (enteredID.match(validpattern))
     isvalidChars = true;
  else
     isvalidChars = false;
  </code></pre>
  
  <p>Test 1: <code>"XAXX0101%&amp;&amp;$#"</code> should fail i.e <code>isvalidChars = false;</code> (as it contains invalid characters like <code>%$#</code>.</p>
  
  <p>Test 2: <code>"XAXX0101&amp;Ñ3Ñ&amp;"</code> should pass. </p>
  
  <p>Test 3: <code>"XA 87B"</code> should fail as it contains space in between</p>
  
  <p>The above code is not working, Can any one help me rectifying the above regex.</p>