gpt4 book ai didi

php - 解析Bibtex文件

转载 作者:行者123 更新时间:2023-12-02 07:41:24 29 4
gpt4 key购买 nike

我想使用php或javascript解析以下bibtex字符串或整个.bib文件。

有什么建议么?

该字符串如下所示:

@article{Sng:2010:PMW:1750585.1750678,
author = {Sng, Colin T. S. and Manlove, David F.},
title = {Popular matchings in the weighted capacitated house allocation problem},
journal = {J. of Discrete Algorithms},
issue_date = {June, 2010},
volume = {8},
number = {2},
month = jun,
year = {2010},
issn = {1570-8667},
pages = {102--116},
numpages = {15},
url = {http://dx.doi.org/10.1016/j.jda.2008.11.008},
doi = {10.1016/j.jda.2008.11.008},
acmid = {1750678},
publisher = {Elsevier Science Publishers B. V.},
address = {Amsterdam, The Netherlands, The Netherlands},
keywords = {Maximum popular matching, Polynomial-time algorithm, Popular matching problem, Priorities, Strict preference lists},
}

最佳答案

我不太记得BibTeX语法,但是我建议转换语法以使其可由JSON.parse解析,如下所示:

var bibjson = bibtex.replace(/(\w+)\s*=\s*\{/g,"\"$1\": \"")
.replace(/\}(?=\s*[,\}])/g,"\"")
.replace(/@(\w+)\s*\{([^,]*)/,"{\"$1\": \"$2\"");
var bibobj = JSON.parse(bibjson);

关于php - 解析Bibtex文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10768747/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com