有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

我有这个文本,我想捕捉

Title : CRB: Genetic Diversity of Endangered Populations of Mysticete Whales: Mitochondrial DNA and Historical Demography Type : Award NSF Org : DEB Latest Amendment Date : August 1, 1991 File : a9000006

Award Number: 9000006 Award Instr.: Continuing grant
Prgm Manager: Scott Collins
DEB DIVISION OF ENVIRONMENTAL BIOLOGY
BIO DIRECT FOR BIOLOGICAL SCIENCES Start Date : June 1, 1990 Expires : November 30, 1992 (Estimated) Expected Total Amt. : $179720 (Estimated) Investigator: Stephen R. Palumbi (Principal Investigator current) Sponsor : U of Hawaii Manoa 2530 Dole Street Honolulu, HI 968222225 808/956-7800

NSF Program : 1127 SYSTEMATIC & POPULATION BIOLO Fld Applictn: 0000099 Other Applications NEC
61 Life Science Biological Program Ref : 9285, Abstract :

          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.

我想匹配“标题”和“摘要”之间的每个字符。我试过(?<;=Title)(.em>)(?=Asbtract)和\bTitle\b(.?)\bAbstract\b,但不起作用。我不知道正确的语法是什么


共 (2) 个答案

  1. # 1 楼答案

    \\bTitle\\b([\\s\\S]*?)\\bAbstract\\b
    

    默认情况下.newlines不匹配。所以使用s标志或[\s\S]

    见演示

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

  2. # 2 楼答案

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

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