I'm trying to learn regex for python and try to get token and session values in the string. I get as in the below but is there a better way from here to get token and session values? here is my code also string:
a ={}
import re
b ="token: d9706bc7-c599-4c99-b55e-bc49cba4bc0d\nsession:NjA5MWE2MGQtMTgxNS00NWY5LTkwYWQtM2Q0MWE3OTFlNTY0\n"
a=re.findall("([A-Za-z]+[\d@]+[\w@]*|[\d@]+[A-Za-z]+[\w@])",b)
print(a[5]) #this is for session value "NjA5MWE2MGQtMTgxNS00NWY5LTkwYWQtM2Q0MWE3OTFlNTY0"
print ([a[0:5]]) #this is for getting token as array d9706bc7 c599 4c99 b55e bc49cba4bc0d
How can I get the token value with - as in the below:
"d9706bc7-c599-4c99-b55e-bc49cba4bc0d"