首页 > 解决方案 > 在 C++ 中删除表情

问题描述

我正在尝试从 C++ 中的字符串中删除表情符号。我已经尝试过正则表达式,但无法做到。

const std::string text = "What are  you doing today .";
const std::regex emoji("[\u1F600|U+1F604]");

std::stringstream result;
std::regex_replace(std::ostream_iterator<char>(result), text.begin(), text.end(), emoji, "");

std::cout << result.str()+"\n";

标签: c++11

解决方案


推荐阅读