単純なプログラミング言語をブースト正規表現で解析したいとしましょう。
import a
import b
class c
今、私はこのようなレイアウトを持ちたいです:
#include <string>
#include <boost/filesystem.hpp>
#include <exception>
using namespace std;
using namespace boost;
using namespace boost::filesystem;
class parser
{
    string _source;
    unsigned int pos;
public:
    parser(const string& source) : _source(source), pos(0) {}
    string expect(const regex& expr)
    {
        string s = next(expr)
        if (s != "")
            return s;
        else
        {           
            --pos;
            throw exception("Expected another expression.");
        }
    }
    string next(const regex& expr)
    {
        // Removing all whitespace before first non-whitespace character
        // Check if characters 0 till x matches regex expr
        // Return matched string of "" if not matched.
    }
    bool peek(const regex& expr);
    parse()
    {
        regex identifier("\a*");
        if (peek("import"))
            string package = expect(identifier);
        else if (peek("class"))
            string classname = expect(identifier);
    }
};
関数 parser::next(const regex&) を定義するためにあなたの助けが必要です。std::string を介してブースト正規表現を反復する方法が明確ではありません。
誰かが私を助けてくれることを願っています!