我该如何设计一个正则表达式来捕获两个字符串之间的所有字符?
具体来说,从这个大字符串开始:
Studies have shown that...[^title=Fish consumption and incidence of stroke: a meta-analysis of cohort studies]... Another experiment demonstrated that... [^title=The second title]
我想提取在
我认为我需要使用re.findall()函数,并且可以从以下代码开始:
Studies have shown that...[^title=Fish consumption and incidence of stroke: a meta-analysis of cohort studies]... Another experiment demonstrated that... [^title=The second title]
我想提取在
[^title=
和]
之间的所有字符,即Fish consumption and incidence of stroke: a meta-analysis of cohort studies
和The second title
。我认为我需要使用re.findall()函数,并且可以从以下代码开始:
re.findall(r'\[([^]]*)\]', big_string)
,这将给我所有方括号[ ]
之间的匹配项,但我不确定如何扩展它。