其他教程

其他教程

Products

当前位置:首页 > 其他教程 >

求一个正则表达式 替换json字符串中的指定键值对

GG网络技术分享 2025-03-18 16:15 5


问题描述:

[code=\"java\"]
{\"name\":\"zhangsan\",\"id\":1042732,\"type\":\"2\",\"status\":0,\"password\":\"123456789\"}
[/code]

如何把其中的type 键值替换成空 我需要一个

[code=\"java\"]
{\"name\":\"zhangsan\",\"id\":1042732,\"status\":0,\"password\":\"123456789\"}
[/code]

求一个正则表达式 匹配\"type\":\"2\",

网友观点:

.replace(/\\\"type\\\":\\\".*?\\\"/,\'type:\\\"\\\"\')

ABnf语法描述-规则说明(二)

上一篇我们列举了Json和XML的例子,并给出了代码片段的语法树。读者应该对ABnf文件的描述规则有一定的感性认识。那么接下来我会把详细的规则一一列举出来。

我们还是以Json为例:

标签:

提交需求或反馈

Demand feedback