【发布时间】:2017-03-16 13:48:19
【问题描述】:
我想从使用 boost 属性树解析的 json Telegram 机器人更新中删除表情符号
我尝试使用这个答案和其他一些答案中的正则表达式模式,但我不确定如何让它们在 C++ 中工作(以下导致崩溃): https://stackoverflow.com/a/24674266/2212021
"message":{
"message_id":123,
"from":{
"id":12345,
"first_name":"name",
"username":"username"
},
"chat":{
"id":12345,
"first_name":"name",
"username":"username",
"type":"private"
},
"date":1478144459,
"text":"this is \ud83d\udca9 a sentence"
}
BOOST_FOREACH(const boost::property_tree::ptree::value_type& child, jsontree.get_child("result"))
{
std::string message(child.second.get<std::string>("message.text").c_str());
boost::regex exp("/[\u{1F600}-\u{1F6FF}]/");
std::string message_clean = regex_replace(message, exp, "");
...
}
在 0x00007FF87C1C7788 处抛出异常 CrysisWarsDedicatedServer.exe:Microsoft C++ 异常: boost::exception_detail::clone_impl > 在内存位置 0x000000001003F138。 CrysisWarsDedicatedServer.exe 中 0x00007FF87C1C7788 处未处理的异常:Microsoft C++ 例外: boost::exception_detail::clone_impl > 在内存位置 0x000000001003F138。
【问题讨论】:
-
这个问题可以使用更多细节:我假设
regex实际上是boost::regex。当你不能让它工作时,你是什么意思?它编译吗?运行时会崩溃吗?或者message_clean没有给你想要的结果(例如,所有的表情符号都还在字符串中)?您是否尝试过使用更简单的正则表达式(例如删除所有数字)来确保regex_replace正常工作?你用的是什么版本的boost? -
道歉;是的,提升::正则表达式。问题是它崩溃了,版本是 boost 1.55
-
它是如何崩溃的,在哪里?
-
尝试附加到该过程。编辑主帖
标签: boost unicode c++03 boost-regex boost-propertytree