0

我正在尝试编写一个使用 C++ 中标准库方法的字符串解析器。我想解析以换行符或';'结尾的传入字符串子字符串。我不断从我创建的正则表达式对象中获取异常。我的模式是:

string pattern = "(.+[\\n\\r;])";
regex cmd_sep(pattern);

我已经尝试过使用和不使用 regex_constants::extended 或基本标志。

4

1 回答 1

0

如果您使用的是 boost 库,最好发布您的错误消息。您可能错过了boost::regex标签。

尝试这个

#include <boost/regex.hpp>
#include <string>
using namespace std;

int main ()
{
    string pattern = "(.+[\\n\\r;])";
    static const boost::regex cmd_sep(pattern);
    return 0;
}
于 2013-04-29T17:13:13.100 回答