import re
regex = re.compile(r"Fig[ures]+\sLege[nds]+?:?$\s*((?:(?!\n\n)\n?[^\n]+)*)", flags=re.IGNORECASE | re.MULTILINE)
test_str = ("Figure legends\n\n"
"Fig. 1 Time course of batch culture with and without additional acetate (working volume, 300 ml). TY medium without additional acetate (A0, a); 2 g/L acetate (A2, b) was supplied as co-carbon source; 4 g/L acetate (A4, c) was supplied as co-carbon source; 6 g/L acetate (A6, d) was supplied as co-carbon source. Symbols: open squares, glucose concentration in broth; open triangles, acetate concentration in broth; closed circles, butanol concentration in broth; closed triangles, acetone concentration in broth; Dashed line, pH of batch culture.\n\n"
"Fig. 2 Mass spectra of butanol and acetone by GC-MS analysis. (a) 12C4-butanol solution as standard substance. (b) Mass spectra of butanol in culture broth of the N1-4 strain with 12C6-glucose and [1, 2-13C2] acetate for 24 h. Peak 1, 2 and 3, indicated by arrows, were derived from three type of butanol: 12C4-butanol, 13C2-butanol in which two out of four carbons were replaced by 13C-atom, and 13C4-butanol, respectively. (c) 12C3-acetone solution as standard substance. (d) Mass spectra of acetone in culture broth of the N1-4 strain with 12C6-glucose and [1, 2-13C2] acetate for 24 h. Peaks 4, 5, 6 and 7, indicated by arrows, were derived from four type of acetone: 12C3-acetone, 13C1-acetone in which one out of three carbons was replaced by 13C-atom, 13C2-acetone in which two out of three carbons were replaced by 13C-atom and 13C3-acetone, respectively. \n\n"
"Fig. 3 Metabolic pathways of fractional 13C-labeling of intermediate metabolites resulting from [1,2-13C2] acetate input by using N1-4 strain. Acetone and butanol molecules composed of different 12C- and 13C-atoms indicate the respective percentages (%) by GC-MS analysis. Each culture (12C6-glucose, 50 g/L; [1,2-13C2] acetate, 4 g/L; working volume, 10 ml) was performed three times, and the average was represented as means ± standard deviation. Labeled 13C-atoms, closed circles; 12C-atoms, open circles; consumed carbon sources concentrations, in boxes and red words; products concentrations, green words. Left side presented data at 9 h (acidogenesis); righ side presented data at 24 h (solventogenesis). Enymes are abbreviated as follows: phosphotransacetylase (PTA); acetate kinase (AK); thiolase (THL); β-hydroxybutyryl dehydrogenase (BHBD); crotonase (CRO); butyryl-CoA dehydrogenase (BCD); CoA transferase (CoAT); acetoacetate decarboxylase (ADC); butyrate kinase (BK); phophotransbutyrylase (PTB); aldehyde/alcohol dehydrogenase (AAD); butanol dehydrogenase I (BDHA); butanol dehydrogenase II (BDHB). Putative approaches for acetate uptake")
match = regex.search(test_str)
if match:
print(f"Match was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html