title: regex: How to match similar strings with the same beginning
body: <p>I need to match expressions with similar beginnings such as:</p>
  
  <ul>
  <li>"ThisExpressionContainsThis<strong>Word</strong>IntheMiddle"</li>
  <li>"ThisExpressionContainsThese<strong>Words</strong>InTheMiddle"</li>
  </ul>
  
  <p>I can get both if the regex is <code>(Words|Word)</code>, but if the regex is <code>(Words|Words)</code>, it will only match <code>Word</code> instead of <code>Words</code> in both strings.</p>
  
  <p>My use case will have those matching terms dynamically and they may come in disorder (I can't guarantee that <code>Words</code> will be before <code>Word</code>). </p>
  
  <p>What's the most appropriate regex trick to match the exact words even if they start with the same characters?</p>
  
  <p>--</p>
  
  <p>To extend my use case, this is the example I'm working on:</p>
  
  <pre><code>  const terms = arrayWithTermsFetchedFromAnotherService.join('|');
    const termsMatcher = new RegExp(`(${terms})`);
  </code></pre>
  
  <p>Update: </p>
  
  <p>I gave examples before with words surrounded by spaces "This expression contains this <strong>Word</strong> in the middle" and the regex <code>\b(Word|Words)\b</code> works, but if the word is part of the string (without spaces), that regex doesn't work. Mine doesn't include spaces.</p>