在字符串

时间:2018-03-24 23:47:58

标签: python

我需要从回归中提取sessionID

Example: !!br.com.return.test.rest.schema.CtresponseResp {error: null, sessionID: c1d840fd-fc2a-4e04-8c21-ffb5a9a58a13}

我只需要c1d840fd-fc2a-4e04-8c21-ffb5a9a58a13

1 个答案:

答案 0 :(得分:0)

试试这个:

import re
p = re.compile(r'\w+\d.+[^\W]')
s = '!!br.com.return.test.rest.schema.CtresponseResp {error: null, sessionID: c1d840fd-fc2a-4e04-8c21-ffb5a9a58a13}'
print(''.join(p.findall(s)))

输出:

c1d840fd-fc2a-4e04-8c21-ffb5a9a58a13