Advertisement
sumandari

regex [] and "timestamp":"

Feb 27th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. import re
  2. hand = open('text.txt')
  3. for line in hand:
  4. line = line.rstrip()
  5. error_message = re.findall('^\[(.+?)\]', line)
  6. time_stamp = re.findall('"timestamp":"(.+)', line)
  7.  
  8.  
  9. if len(error_message) > 0:
  10. print(f"error message: {error_message[0]}, timestamp: {time_stamp[0]}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement