title: PHP MongoDB Regex is accepting parts of words
body: <pre><code>$nameRegEx = new MongoDB\BSON\Regex($userName, 'i');
  $userDB = $userCollection-&gt;findOne(['userName' =&gt; $nameRegEx]);
  </code></pre>
  <p>In my imagination this regex (option i) only says case insensitive as mentioned <a href="https://docs.mongodb.com/manual/reference/operator/query/regex/" rel="nofollow noreferrer">into docs</a></p>
  <p>Given <code>$userName = &quot;go&quot;</code> the curser <code>$userDB</code> would find a document with <code>userName</code> being &quot;g&quot; as well.</p>
  <p>Any suggestions what I am doing wrong ? Do I understand this option in a wrong way ?</p>