Skip to content

Instantly share code, notes, and snippets.

@Park-Developer
Created April 10, 2021 02:24
Show Gist options
  • Save Park-Developer/04ce6624fa9f329204bd1b88dcf1fd50 to your computer and use it in GitHub Desktop.
Save Park-Developer/04ce6624fa9f329204bd1b88dcf1fd50 to your computer and use it in GitHub Desktop.
re module : finditer()
pattern = r"ca"
text = "caabsacasca"
# 매칭된 값은 이터레이터로 모두 반환
iterator = re.finditer(pattern ,text)
for match in iterator:
print match.group() # 1回目: ca 2回目: ca
print match.start() # 1回目: 0 2回目: 6
print match.end() # 1回目: 2 2回目: 8
print match.span() # 1回目: (0, 2) 2回目: (6, 8)
# 출처 : https://ponyozzang.tistory.com/279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment