 <p>This will match exactly the words "Mac" and "ExchangeWebServices" with anything else between them:</p> <pre><code>\bMac\b.*\bExchangeWebServices\b </code></pre> <p>Regex 101 Example: <a href="https://regex101.com/r/sK2qG1/4" rel="nofollow">https://regex101.com/r/sK2qG1/4</a></p>