Created
April 10, 2021 02:24
-
-
Save Park-Developer/04ce6624fa9f329204bd1b88dcf1fd50 to your computer and use it in GitHub Desktop.
re module : finditer()
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
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