Regex to include certain words but exclude another
<p>I am trying to write a regular expression which will check a URL contains certain words and excludes another.</p>

<p>The reason for this is I am trying to track traffic moving through my website and I don't want to count anyone who hits the Thank You page. </p>

<p>So for example:</p>

<ul>
<li><code>http://www.mywebsite.com/register-now/</code> - MATCH</li>
<li><code>http://www.mywebsite.com/contact-us/</code> - MATCH</li>
<li><code>http://www.mywebsite.com/register-now/thank-you</code> - NO MATCH</li>
<li><code>http://www.mywebsite.com/contact-us/thank-you</code> - NO MATCH</li>
<li><code>http://www.mywebsite.com/thank-you</code> - NO MATCH</li>
</ul>

<p>I have 2 words (<code>register-now</code> and <code>contact-us</code>) these must be in the URL. However I must ensure that 1 word (<code>thank-you</code>) is also not in the URL.</p>

<p>I have tried to use a negative lookahead to check that the URL does NOT contain thank-you but It is not working:</p>

<pre><code>"^(?!.*\/thank\-you+)\/(contact\-us|register\-now)\/.*"
</code></pre>