javascript - 在大括号之间获取,包括第一个和最后一个大括号
问题描述
我有的代码:
我想在(包括)第一个花括号到最后一个(包括)之间:
<html lang=3D"pl-US"> <head> </head> <body> <div> <script data-scope=3D"in=
boxmarkup" type=3D"application/json">{
"api_version": "1.0",
"publisher": {
"api_key": "61d9",
"name": "Google Alerts"
},
"entity": {
"external_key": "Google Alert - Adidas"
},
"updates": {
"snippets": [ {
"icon": "BOOKMARK",
"message": "lala (Nike)"
} ]
},
"cards": [ {
"title": "Google Alert - Adidas",
"subtitle": "Nike and Adidas",
"actions": [ {
"name": "Sam",
"url": "https://www.google.com"} ],
"widgets": [ {
"type": "LINK",
"title": "lala (Nike)"
} ]
} ]
}
</script> <!--[if mso]>
<table><tr><td width=3D650>
<![endif]-->
当我使用\{([^()]|())*\}
时,它返回给我一个不包括所有的奇怪的东西(如代码所示)。计划是解析数据并用作 JSON。
我只需要(包括)第一次出现{
和最后一次出现}
.
解决方案
推荐阅读
- angular - 模板驱动表单中的自定义验证器始终返回 null
- apache-nifi - 我可以使用 localhost 而不是 Nifi 集群中的实际节点 IP 地址访问 Nifi Rest-API 吗?
- html - 将一张图片移到另一张图片中
- ios - 单例及其在 swift 中的同步
- powershell - 具有 New-Object 的嵌套 OrderedDictionary 和数组数据结构
- r - 根据其他变量是否为 NA 创建具有值的变量
- python - “导入编码”是什么意思?
- json - 如何禁用 artifact-[build-no].json 文件的创建?
- javascript - 有没有办法在 ASP.NET Core 的控制器中读取由 JavaScript 代码创建的 cookie?
- python - Visual Studio Code:如何在新选项卡而不是新窗口中打开新的 Python 文件