我有以下几段文字:
@article{carr2006,
title={Techniques for qualitative and quantitative measurement of aspects of laser-induced damage important for laser beam propagation},
author={Carr, CW and Feit, MD and Nostrand, MC and Adams, JJ},
journal={Meas. Sci. Technol.},
volume={17},
number={7},
pages={1958},
year={2006},
publisher={IOP Publishing}
}
@article{NIF1998,
author = {Schwartz, Sheldon and Feit, Michael D. and Kozlowski, Mark R. and Mouser, Ron P.},
title = {Current 3-ω large optic test procedures and data analysis for the quality assurance of National Ignition Facility optics},
journal = {Proc. SPIE},
volume = {3578},
number = {},
pages = {314-321},
year = {1999},
}
我一直试图通过它的标签来提取文章,但是我无法理解贪婪/非贪婪是如何工作的,或者更确切地说当它包含更多括号时如何捕获括号中的所有内容:/
以下正则表达式将结果返回到第一个括号,这不是我的目标......
/\{(carr2006[^}]+)\}?/s
还试图在前面用@article捕捉全文,但这也不起作用......
/@*\{(carr2006[^}]+)\}?/s
对我做错的任何解释都会有所帮助:)
答案 0 :(得分:1)
您可以像下面一样更改正则表达式。
@\w+\{1st_standard(?:,\s*\w+\s*=\s*(?:{[^}]*}|"[^"]*"))+,?\s*\}
\s*
应匹配任何类型的空白字符,以便与换行符匹配。