http://code.activestate.com/recipes/499314/

import re
starts = [match.start() for match in re.finditer(re.escape(S), T)]

finditer() won't find overlapping strings. The regular expression methods, including finditer(), find non-overlapping matches. To find overlapping matches you need a loop.
創作者介紹
創作者 wenching520 的頭像
wenching520

牧羊人

wenching520 發表在 痞客邦 留言(0) 人氣()