我有一些这样的内容:
author = "Marjan Mernik and Viljem Zumer",
title = "Implementation of multiple attribute grammar inheritance in the tool LISA",
year = 1999
author = "Manfred Broy and Martin Wirsing",
title = "Generalized
Heterogeneous Algebras and
Partial Interpretations",
year = 1983
author = "Ikuo Nakata and Masataka Sassa",
title = "L-Attributed LL(1)-Grammars are
LR-Attributed",
journal = "Information Processing Letters"
而且我需要抓住title的双引号之间的所有内容。我的第一次尝试是这样的:
^(" "|\t)+"title"" "*=" "*"\"".+"\","
它抓住了第一个例子,但没有抓住其他两个。另一个有多行,这就是问题所在。我想在\n
某处更改为允许多行的东西,如下所示:
^(" "|\t)+"title"" "*=" "*"\""(.|\n)+"\","
但这无济于事,相反,它捕获了一切。
比我虽然,“我想要的是在双引号之间,如果我抓住所有东西,直到我找到另一个"
后跟的东西,
怎么办?这样我就可以知道我是否在标题的末尾,无论行数如何,比如这:
^(" "|\t)+"title"" "*=" "*"\""[^"\""]+","
但这还有另一个问题......上面的例子没有它,但是双引号("
)可以在标题声明之间。例如:
title = "aaaaaaa \"X bbbbbb",
是的,它总是以反斜杠 ( \
) 开头。
有什么建议可以解决这个正则表达式吗?