Files
_Geulbeot/02. Prompts/문서생성/codedomain/멀티라인_대응_Python_v01.py

11 lines
569 B
Python

def get_item_id_with_lookback(ws, row, col, section_start_row):
"""멀티라인 대응 상향 번호 탐색 - 섹션 경계 존중"""
for r in range(row, section_start_row - 1, -1):
# 새로운 섹션을 만나면 탐색 중단
f_val_check = str(ws.cell(row=r, column=6).value or "").strip()
if r != row and re.match(r'^\(.*\)$|^\[.*\]$', f_val_check):
break
# F열에서 번호 탐색
if re.search(ID_MARKER_PATTERN, f_val_check):
return re.search(ID_MARKER_PATTERN, f_val_check).group()