我有一个部分需要匹配。
我的条件是:
匹配包括标题在内的所有内容。标题的模式已经被我匹配了,我需要匹配以单词“fig”开头的段落。我已经做过了,但我注意到,一旦遇到不匹配,它将停止进一步匹配。
另一个条件是,如果一个段落少于3个单词,则不匹配它。在
以下是示例文本:List of tables and figure captions:
Figure 1 shows study area and locations of borewell and surface water sampling points. Low lying area on the western side is clearly visible.
Figure 2 displays nothing much.
no match
here
Fig.y yhth hyt htyh hyt htyh th thyt htyht thh
Table xvnm,mcxnv bvv nd vdm v
段落之间可以有任意数量的行。这里发生的是,在以图2开头的段落的行尾之后,这些单词不匹配,因为它们不是以“Fig”开头,而是后面的句子以“Fig”开头。我怎么可能将这行与Fig.y匹配??在
这是我的正则表达式:
^{pr2}$
使用的标志:re.I,re.M,re.S(DOTALL)
我试着把这个加起来:(?:.*^Fig[^\n]*$){0,}
但是这行不通,因为我找不到方法跳过包含"no match"和{}的行。在
感谢帮助。我将使用re.findall。在