title: Match only part of regexp
body: <p>I need to filter list of names using <code>regex</code>.</p>
  <p>I have stored data in this format</p>
  <pre class="lang-json prettyprint-override"><code>[
   {
    &quot;firstName&quot;: &quot;Jhon&quot;,
    &quot;lastName&quot;: &quot;Doe&quot;,
   },
   ...
  ]
  </code></pre>
  <p>User can enter either full name, first name or last name. But I need to match them all. My mongo query goes like this (I used <code>Loopback 4</code> to build this query but idea is obvious)</p>
  <pre class="lang-js prettyprint-override"><code>        {
            or: [{firstName: new RegExp(searchKey, 'i')}, {lastName: new RegExp(searchKey, 'i')}],
          };
  </code></pre>
  <p>But this does not match when user enters <em>jhon doe</em> but it works when first name or last name only entered.</p>
  <p>My question is, is there a way to match part of the string against regex?</p>
  <p>expected to return successful match for all &quot;jhon&quot;, &quot;doe&quot;, &quot;jhon doe&quot; and &quot;jhondoe&quot;</p>