I am trying to use regex to find all the matched patterns in a BibTex file. The file looks like this:
bib_file = """
@article{Fu_2007_ssr,
doi = {10.1016/j.surfrep.2007.07.001}
}
@article{Shibuya_2007_apl,
doi = {10.1063/1.2816907}
}
"""
My goal is to find all the matched patterns with is from @article to } and put these patterns into a list. So my final list will be like this:
['@article{Fu_2007_ssr,\n doi = {10.1016/j.surfrep.2007.07.001}\n }',
'@article{Shibuya_2007_apl,\n doi = {10.1063/1.2816907}\n }']
Currently, I have my code:
rx_sequence = re.compile(r'(@article(.*)}\n)', re.DOTALL)
article = rx_sequence.search(bib_file).group(1)
But the article is a string, how can I find each matched pattern and append it to a list?
articles= list(rx_sequence.finditer(bib_file))?bibtexparser?