Hello, world! I'm in a regex trouble. I'm using a HTTP API (for searching italian trains) that give me those informations (for example):
10911 - SESTO S. GIOVANNI|10911-S01325
Format:
TRAIN_NUMBER - STATION|TRAIN_NUMBER - STATION_CODE
Until there were few requests all it's ok, because I need only one information, "S01325". But when users began to grow I discovered that there may be two trains with the same numbering. For example, the train 612 can have two numerations, in fact the API gives me:
612 - TARANTO|612-S11465
612 - ASSO|612-N00079
When (using urllib.request module) I try to read this, I get:
b'612 - TARANTO|612-S11465\n612 - ASSO|612-N00079\n'
I need have two list variables:
A = ['612 - TARANTO', '612 - ASSO'] #First regex expression
B = ['S11465', 'N00079'] #Second regex expression
I must use REGEX, true? I never used REGEX, so I don't know what I must do. I searched on Google and on the Wiki(s) / docs. But I don't found (404) the solution of this problem. Obviously the regex expression must works for all cases, for example:
b'2097 - MILANO CENTRALE|2097-S01700\n'
Give me:
A = ['2097 - MILANO CENTRALE']
B = ['S01700']
Another example:
b'123 - ROMA TERMINI|123-S01358\n123 - TREVIGLIO|123-S01703\n'
Give me:
A = ['123 - ROMA TERMINI', '123 - TREVIGLIO']
B = ['S01358','S01703']
Thanks, thanks very much for reading. I hope I was clear. Have a good day, Marco P.S.: Link to the italian docs