如何使用Regex解析Json? [英] How to parse Json using Regex?

查看:169
本文介绍了如何使用Regex解析Json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用正则表达式解析此json数据.但是,我不能. 我试过这样的module.getid(.*),但是没有用.

I want to parse this json data with regex. But, i could not. I tried like this module.getid(.*), but no working.

我只想参加这部分-> module.getid(...)

Only, I want to take this part -> module.getid(...)

module.getid([{"id":"44423"}]); module.getresult([{"result":"false"}]);

我该怎么办?

推荐答案

如果要捕获第一个(演示):

Try this if you want to capture the first (demo):

/module.getid\((.*?)\); *module.getresult(?:.*?)\);$/m

如果您要捕获两个 json 字符串(演示):

If you want to capture both json strings (demo):

/module.getid\((.*?)\); *module.getresult(.*?)\);$/m

这篇关于如何使用Regex解析Json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆