title: PHP regex - how to uniqely match domains?
body: <p>I have two possible URL-s in my web app.</p>
  
  <ol>
  <li>www.domain.com</li>
  <li>www.user.domain.com</li>
  </ol>
  
  <p>Now I need two php regexs that will match each URL uniquely.</p>
  
  <p>I wrote two regexs:</p>
  
  <pre><code>1. (www\.)?(domain)(\.)(com)
  2. (www\.)?([a-z]+)(\.)(domain)(\.)(com)
  </code></pre>
  
  <p>The first one will match first URL.
  The second one will match second URL but it will match first URL too. Thats the problem.</p>
  
  <p>How to write regex to match each of these URLs uniqely?</p>
  
  <p>Here is link to rubular premalink so you can see whats my problem.
  LINK: <a href="http://www.rubular.com/r/QWyANvtXJK" rel="nofollow noreferrer">Rubular</a></p>