title: Match the string starting with initials followed by a valid alphabetic string - Regex
body: <p>I am trying to match a string that starts with (Mr.|Mrs.|Ms.|Dr.|Er.) followed by any string [a-zA-Z] but somehow it is also passing it for "Er.Dr.". </p>
  
  <p>Let me know what I am doing wrong with the regular expression here.</p>
  
  <pre><code>var input = [
      {str: "Mr.X", expectedValue: true},
      {str: "Mrs.Y", expectedValue: true},
      {str: "Dr#Joseph", expectedValue: false},
      {str: "Er .Abc", expectedValue: false},
      {str: "Er.Dr.", expectedValue: false},
      {str: "Er.Abc", expectedValue: true}
  ];
  
  var re = /^(Mr|Mrs|Ms|Dr|Er)\.+[A-Za-z]/;
  
  input.forEach(x =&gt; {
      var answer;
      var matchStr;
      answer = re.test(x.str);
      matchStr = x.expectedValue === answer ? "MATCH" : "NO MATCH";
      console.log("------------------------------------------------------------------------------");
      console.log(`"${x.str}" | Expected Output: ${x.expectedValue} | My Output: ${answer} | ${matchStr}`);
      console.log("------------------------------------------------------------------------------");
  })
  </code></pre>
  
  <p><strong>Output -</strong></p>
  
  <p><a href="https://i.stack.imgur.com/9D9nU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9D9nU.png" alt="Regex 2"></a></p>