Skip to content

Instantly share code, notes, and snippets.

@wonpoo999
wonpoo999 / test.py.txt
Last active October 2, 2025 08:39
[파이썬] n번째 단어 치환-re 모듈
# 01234567890123456789012345678901234567890123
message="GoodBye Java, !! GoodBye Oracle!! Good job!!"
origin = "Good"
dest = "Hi"
n=3
import re
matches = list(re.finditer(origin, message))
# ↪ iter(이터레이터) 를 이용해서 origin 단어를 모두 찾아 list로 저장
# matches 는 찾는 단어의 위치 정보를 포함하는 객체의 list 입니다.
print(matches)