擅长:python、mysql、java
<p>开始:</p>
<pre><code>result = []
regex = re.compile(
r"""^-*\s+
(?P<name>.*?)\s+
\((?P<email>.*?)\)\s+
(?:changed\s+status\s+from\s+(?P<previous>.*?)\s+to|became)\s+
(?P<new>.*?)\s+@\s+
(?P<date>\S+)\s+
(?P<time>\S+)\s+
-*$""", re.VERBOSE)
with open("inputfile") as f:
for line in f:
match = regex.match(line)
if match:
result.append([
match.group("name"),
match.group("email"),
match.group("previous")
# etc.
])
else:
# Match attempt failed
</code></pre>
<p>会给你一组匹配的部分。然后我建议您使用<a href="http://docs.python.org/library/csv.html" rel="noreferrer">^{<cd1>}</a>以标准格式存储结果。</p>