定义一个正则表达式:
var reg = /^\w+\(({[^()]+})\)$/ var mstches = ret.match(reg) if(matches){ ret = JSON.parse(matches[1]) // matches[0]为整个字符串 // matches[1]为匹配到的分组 }