在Python中,如何找到字符串表达式之后的子字符串?

时间:2018-08-27 04:58:42

标签: python regex python-3.x

我目前有一个大字符串big_string,其中包含以下元素:

..."string1":"74f07sdfafeijsfeijfsl","string2":"XRewejffeew","zero_data":{},"string3":"c2d8f4380025",...

我想提取"string2"之后的字符串,以便可以有一个变量:

substring = 'XRewejffeew'

是否可以使用re.findall()来做到这一点?

1 个答案:

答案 0 :(得分:1)

findall('(?<="string2":")\w+', big_string) # Result: 'XRewejffeew'

有关解释,请点击此处:

Getting the text that follows after the regex match