Код: Выделить всё
import re
def show_time_of_pid(line):
pattern=r"^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec).*\d{2}:\d{2}:\d{2}\[(\d+)\]"
result = re.search(pattern, line)
return result
Код: Выделить всё
print(show_time_of_pid("Jul 6 14:01:23 computer.name CRON[29440]: USER (good_user)"))
Код: Выделить всё
Jul 6 14:01:23 pid:29440
Подробнее здесь: https://stackoverflow.com/questions/612 ... me-date-id
Мобильная версия