Created
May 23, 2013 07:46
-
-
Save kenneth/5633351 to your computer and use it in GitHub Desktop.
a newbie regex problem?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
#!/usr/bin/env python | |
import re | |
content=""" | |
[URL="http://www.boston.com/bigpicture/2008/10/the_sun.html"]http://www.boston.com/bigpictu....html[/URL] | |
[url="http://www.boston.com/bigpicture/2008/10/the_sun.html"]http://www.boston.com/bigpictu....html[/url] | |
[URL=http://www.boston.com/bigpicture/2008/10/the_sun.html]http://www.boston.com/bigpictu....html[/URL] | |
[url=http://www.boston.com/bigpicture/2008/10/the_sun.html]http://www.boston.com/bigpictu....html[/url] | |
[url]http://www.boston.com/bigpictu....html[/url] | |
[URL]http://www.boston.com/bigpictu....html[/URL] | |
""" | |
pattern = r'(?i)\[url="?[\s\S]*?\]' | |
for match in re.finditer(pattern, content): | |
print match.group() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
能在这里写么?我想可能应该这样