Re regular matching findall (. +?) Match any content that conforms to a certain format (regular matching catch bullet screen)

demand :
A that cannot be resolved successfully json txt, Only through re To match the corresponding content

What I'm looking for is :

 Insert picture description here
Here's what

Code :

import json
import re
def get_danmu(fname):
with open(fname, 'r', encoding = 'utf-8') as f:
data = f.read()
res = re.findall(r'\\\"content\\\":\\\"(.+?)\\\"', data)
with open("output1.txt", 'w', encoding = 'utf-8') as f:
for each in res:
f.write(each + "\n")
if __name__ == '__main__':
get_danmu("danmu1.txt")

Output :
 Insert picture description here
summary :
1.\ and “ To escape meaning
2.(.+?) Greedy matching


thank
Similar articles

2022-01-15

2022-01-15