擅长:python、mysql、java
<p>我希望此正则表达式正确概括:</p>
<pre><code>with open('path/to/file') as infile, open('/path/to/output', 'w') as outfile:
for line in infile:
if line.startswith('lt="[ ]"'):
hrefs = re.findall("\<a\\s+href=.*\</a\>?", line)
for href in hrefs:
target = href.split('=', 1)[1].split(">", 1)[0].strip('"')
outfile.write("%s\n" target)
</code></pre>
<p>希望这有帮助</p>