djfz-2020-s450026/TaskD05/D05.py

16 lines
367 B
Python
Raw Permalink Normal View History

2020-12-06 23:49:28 +01:00
import re
import sys
def substitute(m):
string = re.sub(r".", "x", m.group(3))
return re.sub(r"(\W*\w+\b\W*)(\w+\b\W*)(\w+)(.*)", r"\1\2"+string+r"\4", m.group(0))
for line in sys.stdin:
match = re.search(r"(\W*\w+\b\W*)(\w+\b\W*)(\w+)(.*)", line)
if match:
print(substitute(match).rstrip("\n"))
else:
print(line.rstrip("\n"))