匹配[key]的正则表达式与Split()

r"\[( *[A-Za-z]*)*\]"

 

def Split(sourceStr):
""" Get a list from sourceStr split by spaces or new lines """
return re.split(" *",sourceStr.replace('\n', ' ').strip())

posted @ 2012-08-28 09:39  G背包  阅读(256)  评论(0编辑  收藏  举报