我有这个字符串:
{"rendererOptions":{"localeStrings":{"renderError":"An error occurred rendering the PivotTable results.","computeError":"An error occurred computing the PivotTable results.","uiRenderError":"An error occurred rendering the PivotTable UI.","selectAll":"Select All","selectNone":"Select None","tooMany":"(too many to list)","filterResults":"Filter values","apply":"Apply","cancel":"Cancel","totals":"Totals","vs":"vs","by":"by"},"rowSubtotalDisplay":{"hideOnExpand":true}},"localeStrings":{"renderError":"An error occurred rendering the PivotTable results.","computeError":"An error occurred computing the PivotTable results.","uiRenderError":"An error occurred rendering the PivotTable UI.","selectAll":"Select All","selectNone":"Select None","tooMany":"(too many to list)","filterResults":"Filter values","apply":"Apply","cancel":"Cancel","totals":"Totals","vs":"vs","by":"by"},"derivedAttributes":{},"hiddenAttributes":[],"hiddenFromAggregators":[],"hiddenFromDragDrop":[],"menuLimit":500,"cols":["clientname","industry"],"rows":["country"],"vals":[],"rowOrder":"key_a_to_z","colOrder":"key_a_to_z","exclusions":{},"inclusions":{},"unusedAttrsVertical":85,"autoSortUnusedAttrs":false,"onRefresh":null,"showUI":true,"sorters":{},"rendererName":"Table With Subtotal","inclusionsInfo":{},"aggregatorName":"Count"}
在此,我想提取字符串中以单词cols:[]
开头的部分。方括号内的值将是动态的,并用双引号引起来。例如在上面的示例中,我要获取的字符串是:"cols":["clientname","industry"]
。注意:我无法控制方括号内的值数量。
我写了这个正则表达式:("cols":\[("\w*",*\])|("cols":\["\w*"\]*))
但显然,我做错了。我需要一些提示来匹配方括号内的1个或多个值。