c++ - 正则表达式 : C++ extract text within double quotes

标签 c++

我只想提取双引号内的单词。所以,如果内容是:

Would "you" like to have responses to your "questions" sent to you via email?

答案一定是

1-你 2-问题

最佳答案

std::string str("test \"me too\" and \"I\" did it");
std::regex rgx("\"([^\"]*)\""); // will capture "me too"
std::regex_iterator current(str.begin(), str.end(), rgx);
std::regex_iterator end;
while (current != end)
    std::cout << *current++;

关于c++ - 正则表达式 : C++ extract text within double quotes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15039421/

相关文章:

c++ - 错误: '.' token 之前应有预期的unqualified-id

c++ - 使用静态 std::vector 类成员时发生访问冲突

c++使用字符串的动态数组不接受字符串

c++ - 字符串类型是标量吗?如果是,为什么?

c++ - clion cmake 项目不编译 : dyld mach-o, 但为模拟器(不是 macOS)构建

c++ - 无法在赋值中将 'listNode**' 转换为 'listNode*'

c++ - 在构造过程中观察变体的状态

c++ - 测试如何验证特定功能是否已执行

c++ - 从函数模板参数自动推断对容器的元素类型

C++:编译器能否优化按值传递?