다음 코드는 주어진 문자열에서 first_id, second_id, category와 같은 데이터를 추출합니다.
예시
import re s = 'TS001B01.JPG' match = re.match(r'(TS\d+)([A|B])(\d+)\.JPG', s) first_id = match.group(1) category = match.group(2) second_id = match.group(3) print first_id print category print second_id
출력
이것은 출력을 제공합니다.
TS001 B 01