title: C++ regex: split the string
body: <p>I am trying to search and split a string based on regex. Suppose I have a string named var which looks like </p>
  
  <pre><code>|   | | |-DeclRefExpr 0x5d91218 &lt;col:5&gt; 'int' lvalue Var 0x5d91120 'y' 'int'
  </code></pre>
  
  <p>Now I would like to split this into </p>
  
  <pre><code>|   | | |-DeclRefExpr 0x5d91218 &lt;col:5&gt; 
  int
   lvalue Var 0x5d91120 
  y
  
  int
  </code></pre>
  
  <p>I know that the regex will be something like [^']* but I cant figure out how I can do it. What I have tried so far is:</p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include &lt;regex&gt;
  
  using namespace std;
  
  int main(){
  
      std::string var = "    |   | | |-DeclRefExpr 0x5d91218 &lt;col:5&gt; 'int' lvalue Var 0x5d91120 'y' 'int'";
  
      std::regex rgx("[^']*");
      std::smatch match;
      if (std::regex_search(var.begin(), var.end(), match, rgx)){
          cout &lt;&lt; match[3] &lt;&lt; endl;
      }
      return 0;
  }
  </code></pre>