python中正则表达式

时间:2022-12-03 18:24:49

正则表达式匹配流程:正则表达式文本compile后得到正则表达式对象,在正则表达式对象中定义了不同的操作提供方法,如模式匹配搜索或字符串替换。
下图展示了使用正则表达式进行匹配的流程: 

python中正则表达式

1. 

    pat_details = re.compile(r'"editorsComments":"(.*?)",', re.MULTILINE | re.DOTALL)
    
    script_details= pat_details.findall(data_scrip.text)
2.
image_list1=re.findall(r'data-index.+?<img class.+?src="(.+?\.jpg)"', html, re.S)