import re def extract_digits(file_path): pattern = r'^(\d{2})-\d{3}$' with open(file_path, 'r', encoding='utf-8') as file: for line in file: match = re.match(pattern, line.strip()) if match: print(match.group(1)) else: print("") file_path = 'TaskE02/test.in' extract_digits(file_path)