1

EDIT: DONE ALREADY! THANKS

Code as below:

import ast,re

a = "('=====================================', '30/06/2016 17:15 T001 -------------------------------')"

t=ast.literal_eval(a)

z=re.compile(r"(\d\d/\d\d/\d\d\d\d)\s(\d\d:\d\d)")

m = z.match(t[1])

if m:
    print("date: {}, time {}".format(m.group(1),m.group(2)))

1 Answer 1

1

You can iterate list items, and match those items.

t = ast.literal_eval(a)  # assuming `t` is an iterable
z = re.compile(r"(\d\d/\d\d/\d\d\d\d)\s(\d\d:\d\d)")
for item in t:   # <-----
    m = z.match(item)
    if m:
        print("date: {}, time {}".format(m.group(1), m.group(2)))
        # break  # if you want to get only the first matched data/time pair
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.