I have a sting containing multiple informations which I want to save in a dictionary:
s1 = "10:12:01 R1 3 E44"
s2 = "11:11:01 R100 E400"
pattern = "\d{2}:\d{2}:\d{2}(\,\d+)?" + \
" +" + \
"[0-9A-Za-z _]{2}([0-9A-Za-z _]{1})?([0-9A-Za-z _]{1})?" + \
" +" + \
"[0-9A-Za-z _]{2}([0-9A-Za-z _]{1})?([0-9A-Za-z _]{1})?$"
# -->
d1 = {"time" : "10:12:01",
"id1" : "R1 3",
"id2" : "E44"}
d2 = {"time" : "11:11:01",
"id1" : "R100",
"id2" : "E400"}
is there a way doing this directly with python re?
Note: I'm aware that there is a similar question here: regex expression string dictionary python, however the formulation is not precisly pointing to what I expact as answer.