正则表达式匹配文档中两个字符串之间的所有字符

时间:2015-11-04 04:47:28

标签: java regex regex-lookarounds

我有这个我要捕获的文本

  

标题:CRB:濒危群体的遗传多样性   Mysticete鲸鱼:                  线粒体DNA和历史人口类型:奖NSF组织:DEB最新修订日期:8月1日,   1991年档案:a9000006

     

奖励编号:9000006奖励Instr。:持续授权
  Prgm经理:Scott Collins
          环境生物学DEB分部           BIO直接生物科学开始日期:1990年6月1日到期日:1992年11月30日(估计)   预计总金额。 :$ 179720(估计)调查员:   Stephen R. Palumbi(首席研究员)赞助商:U   夏威夷马诺阿           多尔街2530号           檀香山,HI 968222225 808 / 956-7800

     

NSF计划:1127 SYSTEMATIC&人口生物学适用范围:   0000099其他应用NEC
                61生命科学生物计划参考号:9285,摘要

          Commercial exploitation over the past two hundred years drove                  
          the great Mysticete whales to near extinction.  Variation in                   
          the sizes of populations prior to exploitation, minimal                        
          population size during exploitation and current population                     
          sizes permit analyses of the effects of differing levels of                    
          exploitation on species with different biogeographical                         
          distributions and life-history characteristics.  Dr. Stephen                   
          Palumbi at the University of Hawaii will study the genetic                     
          population structure of three whale species in this context,                   
          the Humpback Whale, the Gray Whale and the Bowhead Whale.  The                 
          effect of demographic history will be determined by comparing                  
          the genetic structure of the three species.  Additional studies                
          will be carried out on the Humpback Whale.  The humpback has a                 
          world-wide distribution, but the Atlantic and Pacific                          
          populations of the northern hemisphere appear to be discrete                   
          populations, as is the population of the southern hemispheric                  
          oceans.  Each of these oceanic populations may be further                      
          subdivided into smaller isolates, each with its own migratory                  
          pattern and somewhat distinct gene pool.  This study will                      
          provide information on the level of genetic isolation among                    
          populations and the levels of gene flow and genealogical                       
          relationships among populations.  This detailed genetic                        
          information will facilitate international policy decisions                     
          regarding the conservation and management of these magnificent                 
          mammals.

我希望匹配“标题”和“摘要”之间的每个字符。我试过(?&lt; = Title)(。)(?= Asbtract) \ bTitle \ b(。 < / em> ?)\ bAbstract \ b ,但没有用。我无法弄清楚,正确的语法是什么。

2 个答案:

答案 0 :(得分:3)

\\bTitle\\b([\\s\\S]*?)\\bAbstract\\b
默认情况下,

.newlines不匹配。请使用s标记或[\s\S]

参见演示。

https://regex101.com/r/lR1eC9/6

答案 1 :(得分:0)

您应该使用以下正则表达式:

Title\s*\:(.*?)Abstract\s*\: