Python 正则表达式匹配两个指定字符串中间的内容
A(.*?)B 表示截取 A/B 中间的字符串
import re txt='@font-face{font-family:"customfont"; src:url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAACHMAHUrlQa1/U/GjaKLvBmPZEW9aysrJJd8fcdtKlebEw+i+9+ss+zY9V28te/XU+6HyW/QK0Vmv==)' bs64_str = re.findall("charset=utf-8;base64,(.*?)\)", txt)[0] print(bs64_str)
执行结果:
d09GRgABAAAAACHMAHUrlQa1/U/GjaKLvBmPZEW9aysrJJd8fcdtKlebEw+i+9+ss+zY9V28te/XU+6HyW/QK0Vmv==