title: How to use <regex> in C++11
body: <p>I'm trying to use a regular expression to accept strings that have sequences like</p>
  
  <pre><code>ifelseifelseififif
  </code></pre>
  
  <p>So every else needs an if, but not every if needs an else. I know I could do this with pen and paper with a simple regular expression like this <code>((if)*+(ifelse)*)*</code> .Now I'm not sure if I'll be able to do this with the  library as I've never used it before. So would it be possible to accept or reject a string based on a regular expression like the one I wrote above?</p>
  
  <p>I wrote this sample to get my feet wet and I don't understand why it returns false. Isn't regex_search() supposed to find substring matches? That snippet prints nope every time.</p>
  
  <pre><code>#include &lt;regex&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  int main(){
    string sequence="ifelse";
    regex rx("if");
    if(regex_search(sequence.begin(),sequence.end(),rx)){
      cout&lt;&lt;"match found"&lt;&lt;endl;
    }else{
      cout&lt;&lt;"nope"&lt;&lt;endl;
    }
  }
  </code></pre>
  
  <p>I'm using g++ 4.7 and have tried compiling with both <code>g++ -std=gnu+11 reg.cpp</code>  and <code>g++ -std=c++11 reg.cpp</code></p>