我在分析一些引文模式,每个句子都有字符串,通常是这样的
Various chemogenomics [<xref ref-type="bibr" rid="pone.0204999.ref008">8</xref>] methods have been proposed in the last decade [<xref ref-type="bibr" rid="pone.0204999.ref010">10</xref>–<xref ref-type="bibr" rid="pone.0204999.ref024">24</xref>] and also this one [<xref ref-type="bibr" rid="pone.0204999.ref008">8</xref>].
当我试图在一个句子中找到所有的引文时,我找到了
>10<\/xref>–<xref ref-type="bibr" rid="pone.0204999.ref024">24<\/xref>
理想情况下,我能够用方括号(即字符串)识别(并替换)完整的引用
[<xref ref-type="bibr" rid="pone.0204999.ref010">10</xref>–<xref ref-type="bibr" rid="pone.0204999.ref024">24</xref>]
只知道我能匹配的那根弦。我想知道是否有可能采取匹配字符串,并包括所有文本到最近的方括号?你知道吗
我可以在匹配字符串后使用lazy.*?]
regex术语匹配右方括号,但不能对左括号执行相同的操作,因为它将找到句子的第一个左括号,而不是最接近匹配字符串的左括号。你知道吗
是的,例如从匹配中排除左方括号,如下所示:
参见regex101上的最小示例
相关问题 更多 >
编程相关推荐