Here is my solution.
def show_time_of_pid(line): pattern = r"(\w+ \d [\d:]+)([\S ]+)\[(\d+)\]" result = re.search(pattern, line) return "{} pid:{}".format(result.group(1), result.group(3))