我想在字符串中找到一些非常特定的数据。问题是我没有找到我正在使用的当前正则表达式的所有数据。下面是一些示例数据:Python re.findall正则表达式问题
[img:2gcfa9cc]http://img823.imageshack.us/img823/3295/pokaijumonlogo.jpg[/img:2gcfa9cc]
Making these little guys into Kaiju monsters. Again, I know nothing about them, other then which ones I thought would make for cool possible Kaiju (of the original 150) so here's Day 01
[b:2gcfa9cc][size=150:2gcfa9cc]BULBASAUR[/size:2gcfa9cc][/b:2gcfa9cc]
[i:2gcfa9cc]Feb 01[/i:2gcfa9cc]
[ddf2k12:2gcfa9cc]http://img853.imageshack.us/img853/2185/dailydrawfeb2012day01.jpg[/ddf2k12:2gcfa9cc]
Setting myself up with the same "parameters" as last year
I may be breaking my own Challenge rules right now but...well I started this last night and I couldn't just leave 'em out in the cold all unfinished 'n' shit.
Obligatory Skyrim drawing.
[ddf2k12:2ytorpmj]http://4.bp.blogspot.com/-UIUSNXvnHz4/TynYf1BZ9oI/AAAAAAAAAl4/pRLHVP0Ny3U/s1600/01_cheatingcheaterwarmup1.jpg[/ddf2k12:2ytorpmj]
我试图让是ddf2k12
标签和标签img
之间的数据。我到目前为止只在ddf2k12
标签上工作过(我认为后者将是img而不是ddf2k12
),而在我应该找到的1586个标签中,我只得到5个。下面是我的正则表达式:
ddf2k12_regex = '(\[[ddf2k12]+\:[A-Za-z0-9]+\])(.*?)(\[[ddf2k12]+\:[A-Za-z0-9]+\])'
ddf2k12_find = re.findall(ddf2k12_regex, post)
很明显,我的正则表达式有些问题,但是在将我的头撞到墙上之后,我无法将其整理出来,所以我们不胜感激。谢谢。
好多了!不过,我仍然想知道点在新行上卡住了。 – tchrist 2012-03-03 18:50:10
是的!非常感谢,完美运作。是的,让它更清晰明确是一个更好的举措。我更喜欢使用%s标签来连接字符串,但那是我做的唯一不同的事情。再次感谢! – 2012-03-03 19:13:51
不客气。 25代表使它完全值得;) – bukzor 2012-03-03 20:19:44