我有这个字符串:
"var block = new MatchesBlock('page_competition_1_block_competition_matches_summary_5', 'block_competition_matches_summary', {"page":0,"bookmaker_urls":{"13":[{"link":"http:\/\/www.bet365.com\/home\/?affiliate=365_178981","name":"Bet 365"}]},"block_service_id":"competition_summary_block_competitionmatchessummary","round_id":42011,"outgroup":false,"view":2,"competition_id":13});"
我想得到:
{"page":0,"bookmaker_urls":{"13":[{"link":"http:\/\/www.bet365.com\/home\/?affiliate=365_178981","name":"Bet 365"}]},"block_service_id":"competition_summary_block_competitionmatchessummary","round_id":42011,"outgroup":false,"view":2,"competition_id":13}
所以我写道:
MatchesBlock\(([^)]+)\)
但这会占用MatchesBlock
答案 0 :(得分:0)
答案 1 :(得分:0)
如果您只想从MatchesBlock
构造函数参数中提取JSON,只需使用以下正则表达式:
\{(?:[^{}]|(?R))*\}
输入:
var block = new MatchesBlock('page_competition_1_block_competition_matches_summary_5', 'block_competition_matches_summary', {"page":0,"bookmaker_urls":{"13":[{"link":"http:\/\/www.bet365.com\/home\/?affiliate=365_178981","name":"Bet 365"}]},"block_service_id":"competition_summary_block_competitionmatchessummary","round_id":42011,"outgroup":false,"view":2,"competition_id":13});
输出:
{"page":0,"bookmaker_urls":{"13":[{"link":"http:\/\/www.bet365.com\/home\/?affiliate=365_178981","name":"Bet 365"}]},"block_service_id":"competition_summary_block_competitionmatchessummary","round_id":42011,"outgroup":false,"view":2,"competition_id":13}
答案 2 :(得分:0)