title: Regex for alphanumeric string with at least 1 number and 1 character and a fixed length of 11
body: <p>I need regex to match an alphanumeric string exact 11 characters long but the value must contain at least both 1 character and 1 number. </p>
  
  <p>Used a combination of
  <a href="https://stackoverflow.com/questions/7684815/regex-for-alphanumeric-with-at-least-1-number-and-1-character][1]">Regex for alphanumeric with at least 1 number and 1 character</a></p>
  
  <p>i.e. <code>/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/</code></p>
  
  <p>and <a href="https://stackoverflow.com/questions/3658145/what-is-the-regex-to-match-an-alphanumeric-6-character-string][1]">What is the regex to match an alphanumeric 6 character string?</a></p>
  
  <p>i.e. <code>^[a-zA-Z0-9]{6,}$</code></p>
  
  <p>by using OR (||) operator like this</p>
  
  <pre><code>//regex code
  var str = "";
  if ($.trim($("input[id$='txtBranchName']").val()) != "")
      str = $.trim($("input[id$='txtBranchName']").val());
  var reg_exp = /^(?:[0-9]+[a-z]|[a-z]+[0-9])[a-z0-9]*$/i; // /^[a-zA-Z0-9]{11,}$/;//^(\d)(?:\1+)?$/; // new RegExp('([0-9]){6}');
  var reg_exp2 = /^[a-zA-Z0-9]{11,11}$/;
  if (!reg_exp.test(str) || !reg_exp2.test(str)) {
      $("span[id$='lblError']").css("color", "red");
      $("span[id$='lblError']").html($("span[id$='lbl_PayeeInformation_IFSCNo']").html()).show();
      $("input[id$='txtBranchName']").focus();
      returned = false;
      return false;
  }
  //end regex code
  </code></pre>
  
  <p>but it would be great if i get it in one regex.</p>