求助 正则表达式
有一个字符串是个script,现在要取其中的WXM.DATA = {
ROOT : WXM.ROOT,...}部分的数据,这个正则该怎么写呢?求助中...O(∩_∩)O谢谢
字符串代码:
<script type="text/javascript">
document.domain = document.location.hostname.match(/[^\.]+\.com/)[0];
var CGI_ROOT = WXM.ROOT.cgi;
WXM.StaticPath = {
recorder : "http://res.wx.qq.com/mpres/zh_CN/htmledition/plprecorder/recoder1191e9.html",
plprecorder: "http://res.wx.qq.com/mpres/zh_CN/htmledition/plprecorder/plprecorder1191e9.swf",
installer: "http://res.wx.qq.com/mpres/zh_CN/htmledition/plprecorder/expressInstall1191e9.swf",
video : "http://res.wx.qq.com/mpres/zh_CN/htmledition/plprecorder/video-js1191e9.swf",
audio : "http://res.wx.qq.com/mpres/zh_CN/htmledition/plprecorder/audiojs1191e9.swf",
rimgcrop : "http://res.wx.qq.com/mpres/htmledition/images/cut-round125122.gif"
};
WXM.DATA = {};
WXM.DATA.userinfo = {};
WXM.DATA = {
ROOT : WXM.ROOT,
userinfo : {
NickName : "yoyo",
FakeID : "2391433120"
},
nav : [
{
_id: 'home',
name : "首页",
link : '/cgi-bin/indexpage?t=wxm-index&lang=zh_CN'
},
{
_id: 'realmsg',
name : "实时消息",
link : '/cgi-bin/getmessage?t=wxm-message&lang=zh_CN&count=50'
}
]}
</script>
------解决方案-------------------- string str = File.ReadAllText("D:\\1.txt", Encoding.Default);
str = Regex.Match(str, @"(?<=WXM\.DATA\s*=\s*{(?!}))((?<g>{)
------解决方案--------------------(?<-g>})
------解决方案--------------------[^{}])*(?(g)(?!))(?=})").Value;