title: PHP preg_match - capturing attributes that use either double or single quotes
body: <p>I have a regular expression that looks into HTML files and finds elements based off if they match a regular expression I pass in. One main thing that determines if the element is matched is what the id is. The id has to be some special characters that I decided to use. The problem is, I know that some people will use either double OR single quotes when writing ids in HTML. I want to be able to catch either case. So my regular expression is this:</p>
  
  <pre><code>preg_match('@(&lt;)([^\s]*).*(id)\s*=\s*["|\']{{ALViewElement_'.$viewElement.'}}["|\'][^/]*?(&gt;)@i', $viewFile, $elementMatches, PREG_OFFSET_CAPTURE)
  </code></pre>
  
  <p>Close to the middle you'll see where I have <code>id</code>. After the equals sign I have <code>["|\']</code> and then at the end I have the same thing for the closing quote.</p>
  
  <p>If my html looks like this, I get a match:</p>
  
  <pre><code>&lt;section  id="{{ALViewElement_resume}}" data-test="testing" &gt;
              &lt;!--{{RESUME_ADD_CHANGE_PIECE}}--&gt;
              &lt;!--{{RESUME}}--&gt;
          &lt;/section&gt;
  </code></pre>
  
  <p>However, if I use single quotes instead, it doesn't match:</p>
  
  <pre><code>&lt;section  id='{{ALViewElement_resume}}' data-test="testing" &gt;
              &lt;!--{{RESUME_ADD_CHANGE_PIECE}}--&gt;
              &lt;!--{{RESUME}}--&gt;
          &lt;/section&gt;
  </code></pre>
  
  <p>I can't seem to figure out what's wrong with my regular expression that it won't pick up the single quotes. Any ideas?</p>