Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个使用 C++ 中标准库方法的字符串解析器。我想解析以换行符或';'结尾的传入字符串子字符串。我不断从我创建的正则表达式对象中获取异常。我的模式是:
string pattern = "(.+[\\n\\r;])"; regex cmd_sep(pattern);
我已经尝试过使用和不使用 regex_constants::extended 或基本标志。
如果您使用的是 boost 库,最好发布您的错误消息。您可能错过了boost::regex标签。
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; }