<p>这个正则表达式呢:</p>
<pre><code>(\[\"[^\"]*\",\"[^\"]*\",\"[^\"]*\"\],\s*\[\"[^\"]*\",\"[^\"]*\",\"[^\"]*\"\])
</code></pre>
<p>演示:</strong></p>
<p><a href="https://regex101.com/r/LaddaK/2/" rel="nofollow noreferrer">https://regex101.com/r/LaddaK/2/</a></p>
<p><strong>解释:</strong></p>
<ul>
<li>圆括号<code>()</code>用于创建捕获组,如果不需要,可以删除</li>
<li><code>\[\"[^\"]*\",\"[^\"]*\",\"[^\"]*\"\]</code>要匹配开括号,请按字面顺序后跟双引号、0到N个非双引号字符(<code>[^\"]*</code>),后跟双引号和逗号。如果要接受逗号周围的空格字符,则可能必须将所有逗号用<code>\s*</code>括起来。你知道吗</li>
<li>再重复2次模式<code>\"[^\"]*\"</code>,以匹配括号中的前3个单词(根据字符串的确切约束,可能需要调整为<code>\w*</code>)。你知道吗</li>
<li>在<code>,\s*</code>之后重复整个块<code>[\"[^\"]*\",\"[^\"]*\",\"[^\"]*\"\]</code>,以接受由两个方括号块组成的整个模式。你知道吗</li>
</ul>
<p><strong>备注:</strong></p>
<ul>
<li><p>您可能希望用锚(<code>^</code>和<code>$</code>)包围regex</li>
<li><blockquote>
<p><strong><em>I don't know exactly your constraints but if you want to analyse some JSON or parse any other format with infinite nested patterns repeating themselves (ex: fractals) you should not use regex.</em></strong> </p>
</blockquote></li>
</ul>
<p><strong>更改要求后编辑:</strong></p>
<pre><code>import re
inputStr = '[dimSales,Product Title,All], [test,Product Title,All]'
print(re.findall(r'\[(?:[a-zA-Z0-9 ]*)(?:,[a-zA-Z0-9 ]*)*\]', inputStr))
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>['[dimSales,Product Title,All]', '[test,Product Title,All]']
</code></pre>