27 lines
567 B
Python
27 lines
567 B
Python
import re
|
|
import sys
|
|
|
|
|
|
def replaceThirdWordWithX(input):
|
|
group1 = input.group(1)
|
|
empty1 = input.group(2)
|
|
group2 = input.group(3)
|
|
empty2 = input.group(4)
|
|
group3 = "x" * (len(input.group(5)))
|
|
rest = input.group(6)
|
|
return f'{group1}{empty1}{group2}{empty2}{group3}{rest}'
|
|
|
|
|
|
pattern = r'(\w+)(\W+)(\w+)(\W+)(\w+)(.*)'
|
|
|
|
for line in sys.stdin:
|
|
line = line.strip('\n')
|
|
|
|
match = re.match(pattern, line)
|
|
if match:
|
|
result = replaceThirdWordWithX(match)
|
|
print(re.sub(pattern, result, line))
|
|
else:
|
|
print(line)
|
|
|