jfz-2023-s473564/TaskF01/run.py

11 lines
358 B
Python
Raw Normal View History

2024-01-19 15:20:29 +01:00
import re
def process_file(file_path):
with open(file_path, 'r',encoding='utf-8') as file:
for line in file:
modified_line = re.sub(r'\b(?:[A-Z]+\w*[a-z]+\w*|[a-z]+\w*[A-Z]+\w*)\b', lambda match: match.group(0).swapcase(), line)
print(modified_line, end='')
file_path = 'polish_wiki_excerpt.exp'
process_file(file_path)