c++ - 无法使用 regex_search 匹配大括号
问题描述
我正在尝试使用 smatch 捕获大括号的位置:
smatch l, r, m;
auto closing = regex_search(ns, r, regex("\}"));
这段代码给了我运行时错误:
libc++abi: terminating with uncaught exception of type std::__1::regex_error: The parser did not consume the entire regular expression.
我也在这里捕获:
regex_search(s, m, regex("\"menu\"\s*:\s*\{"))
这给了我另一个:
libc++abi: terminating with uncaught exception of type std::__1::regex_error: One of *?+{ was not preceded by a valid regular expression.
我的文字是这样的:
"{ \"kvakushka\": { \"popup\": { \"menuitem\": [ \"mur\", \"koshka\", { \"mur\": \"kva\", \"vas\": \"gas\" } ] } }, \"menu\": { \"id\": \"file\", \"value\": \"File\", \"popup\": { \"menuitem\": [ \"file\", \"vasya\" ] }, \"menuitem\": [ { \"value\": \"Font\" }, { \"value\": \"Size\" } ] }, \"wisp\": { \"popup\": { \"menuitem\": [ \"mur\" : 5, \"var\" : 10 ] } }}"
解决方案
推荐阅读
- c# - 如何创建允许我根据网格移动精灵/对象的 C# 脚本
- google-apps-script - 在 Clockify 中启动计时器的 Google 脚本
- javascript - javascript中文件中对象的单个实例
- javascript - func.apply with THIS 适用于任何对象
- amazon-web-services - 在 aws route 53 上为 Spot 实例创建记录集
- java - 读取 10 个 csv 文件并将其存储在数据库中
- c# - 连接到服务器时出现 gRPC RpcException
- php - 尝试将 $_SESSION 参数化为查询的解析错误
- android - 我无法通过单击 Android Studio 中的按钮来获取日志事件
- dataframe - Spark中的内存分配(df)