21 lines
506 B
Python
21 lines
506 B
Python
import re
|
|
import sys
|
|
|
|
def remove_non_digits(line):
|
|
|
|
return re.sub(r'[^0-9\s]', '', line)
|
|
|
|
|
|
processed_lines = []
|
|
|
|
for line in sys.stdin:
|
|
processed_line = remove_non_digits(line)
|
|
processed_line = re.sub(r'^\s+|\s+$', '', processed_line)
|
|
processed_line = re.sub(r'\s+', ' ', processed_line)
|
|
|
|
digit_groups = re.findall(r'\d+', processed_line)
|
|
|
|
if digit_groups:
|
|
processed_lines.append(' '.join(digit_groups))
|
|
|
|
print('\n'.join(processed_lines), end='') |