擅长:python、mysql、java
<p><strong>使用pyparsing</strong></p>
<p>注意:这是一种方法,但大脑并没有处于解析模式-所以这是一个<em>想法</em>而不是一个<em>正确的</em>答案。。。这当然需要一些工作,但可能是正确的方向。。。在</p>
<p>一个使用<code>pyparsing</code>的有点混乱的例子。。。(如果使用@INBOOK和wotsit进行检查和解析,可能会更好,但无论如何……)</p>
<pre><code>from pyparsing import *
keywords = originalTextFor(Keyword('keywords') + '=')
values = delimitedList(Regex('[^;}]+'), ';')
values.setParseAction(lambda L: ', '.join(L))
</code></pre>
<p>其中<code>text</code>是您的示例:</p>
^{pr2}$