std::string s = "select * form aaa \n /*mmmuuu*/ \n \n yuan hs";
boost::xpressive::sregex reg1 = boost::xpressive::sregex::compile("(\\n)|^(//.*? \\n\\s*)|(/\\*(.|\\n)*?\\*/\\s*)");
std::string sEx = boost::xpressive::regex_replace(s, reg1, "");
boost::xpressive::sregex reg1 = boost::xpressive::sregex::compile("(\\n)|^(//.*? \\n\\s*)|(/\\*(.|\\n)*?\\*/\\s*)");
std::string sEx = boost::xpressive::regex_replace(s, reg1, "");

本文介绍了一种使用C++与Boost库中的正则表达式来清理字符串的方法。通过实例展示了如何去除SQL查询字符串中的换行符及注释,实现了字符串的有效清洗。
1654

被折叠的 条评论
为什么被折叠?



