title: Use of std::regex_iterator<std::string::iterator> according to CPlusPlus.com
body: <p>I'm reading the documentation on <code>std::regex_iterator&lt;std::string::iterator&gt;</code> since I'm trying to learn how to use it for parsing HTML tags. The example the site gives is</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;regex&gt;
  
  int main ()
  {
    std::string s ("this subject has a submarine as a subsequence");
    std::regex e ("\\b(sub)([^ ]*)");   // matches words beginning by "sub"
  
    std::regex_iterator&lt;std::string::iterator&gt; rit ( s.begin(), s.end(), e );
    std::regex_iterator&lt;std::string::iterator&gt; rend;
  
    while (rit!=rend) {
      std::cout &lt;&lt; rit-&gt;str() &lt;&lt; std::endl;
      ++rit;
    }
  
    return 0;
  }
  </code></pre>
  
  <p>(<a href="http://www.cplusplus.com/reference/regex/regex_iterator/regex_iterator/" rel="nofollow">http://www.cplusplus.com/reference/regex/regex_iterator/regex_iterator/</a>)</p>
  
  <p>and I have one question about that: If <code>rend</code> is never initialized, then how is it being used meaningfully in the <code>rit!=rend</code>?</p>
  
  <p>Also, is the tool I should be using for getting attributes out of HTML tags? What I want to do is take a string like <code>"class='class1 class2' id = 'myId' onclick   ='myFunction()' &gt;"</code> and break in into pairs </p>
  
  <p>(<code>"class"</code>, <code>"class1 class2"</code>), (<code>"id"</code>, <code>"myId"</code>), (<code>"onclick"</code>, <code>"myFunction()"</code>)</p>
  
  <p>and then work with them from there. The regular expression I'm planning to use is</p>
  
  <pre><code>([A-Za-z0-9\\-]+)\\s*=\\s*(['\"])(.*?)\\2
  </code></pre>
  
  <p>and so I plan to iterate through expression of that type while keeping track of whether I'm still in the tag (i.e. whether I've passed a <code>'&gt;'</code> character). Is it going to be too hard to do this?</p>
  
  <p>Thank you for any guidance you can offer me.</p>