title: How to make Boost.Spirit.Lex token value be a substring of matched sequence (preferably by regex matching group)
body: <p>I'm writing a simple expressions parser. It is build on a Boost.Spirit.Qi grammar based on Boost.Spirit.Lex tokens (Boost in version 1.56).</p>
  
  <p>The tokens are defined as follows:</p>
  
  <pre><code>using namespace boost::spirit;
  
  template&lt;
      typename lexer_t
  &gt;
  struct tokens
      : lex::lexer&lt;lexer_t&gt;
  {
      tokens()
          : /* ... */,
            variable("%(\\w+)")
      {
          this-&gt;self =
              /* ... */ |
              variable;
      }
  
      /* ... */
      lex::token_def&lt;std::string&gt; variable;
  };
  </code></pre>
  
  <p>Now I would like the <code>variable</code> token value to be just the name (the matching group <code>(\\w+)</code>) without prefix <code>%</code> symbol. How do I do that?</p>
  
  <hr>
  
  <p>Using a matching group by itself doesn't help. Still value is full string, including the prefix <code>%</code>.</p>
  
  <p>Is there any way to force using of a matching group?</p>
  
  <p>Or in at least somehow refer to it within action of the token?</p>
  
  <hr>
  
  <p>I tried also using action like this:</p>
  
  <pre><code>variable[lex::_val = std::string(lex::_start + 1, lex::_end)]
  </code></pre>
  
  <p>but it failed to compile. Error claimed that none of the <code>std::string</code> constructor overloads could match arguments:</p>
  
  <pre><code>(const boost::phoenix::actor&lt;Expr&gt;, const boost::spirit::lex::_end_type)
  </code></pre>
  
  <hr>
  
  <p>Even simpler</p>
  
  <pre><code>variable[lex::_val = std::string(lex::_start, lex::_end)]
  </code></pre>
  
  <p>failed to compile. With similar reason only first argument type was now <code>boost::spirit::lex::_start_type</code>.</p>
  
  <hr>
  
  <p>Finally I tried this (even though it looks like a big waste):</p>
  
  <pre><code>lex::_val = std::string(lex::_val).erase(0, 1)
  </code></pre>
  
  <p>but that also failed to compile. This time compiler was unable to convert from <code>const boost::spirit::lex::_val_type</code> to <code>std::string</code>.</p>
  
  <hr>
  
  <p>Is there any way to deal with this problem?</p>