Notepad++ 在行之间查找

Notepad++ 在行之间查找

我想知道两行特定行之间是否存在“重复”的文本片段。

例如,我想找出第一个“TestMethod”中两次“TC.Requirement”的集合。

    [TestMethod()]
    [TestProperty(TC.Name, "")]
    [Description("A test for ")]
    [TestProperty(TC.InternalTcId, "2c80e355-c156-4fd1-ba10-bdfb50f67828")]
    [Owner("")]
    [TestProperty(TC.CreationDate, "")]
    [TestProperty(TC.Requirement, "1111")]
    [TestProperty(TC.PostCondition, "")]
    [TestProperty(TC.PreCondition, "")]
    [TestProperty(TC.Types, TCType.Normal_Case)]
    [TestProperty(TC.Requirement, "2222")]
    [TestProperty(TC.ReviewDate, "")]
    public void ATest()
    {
        Assert.IsNotNull(target);
    }


    [TestMethod()]
    [TestProperty(TC.Name, "")]
    [Description("A test for ")]
    [TestProperty(TC.InternalTcId, "8d00d256-86fe-4a08-864c-6f1bf38581ce")]
    [Owner("")]
    [TestProperty(TC.CreationDate, "")]
    [TestProperty(TC.PostCondition, "")]
    [TestProperty(TC.PreCondition, "")]
    [TestProperty(TC.Types, TCType.Normal_Case)]
    [TestProperty(TC.Requirement, "3333")]
    [TestProperty(TC.ReviewDate, "")]
    public void BTest()
    {
        Assert.IsNotNull(target);
    }

在第一个 TestMethod 中,有双重 Requirement-aatribute,而在第二个 TestMethod 中却没有第二个。

您能帮我找出该搜索的正则表达式吗?

谢谢 :-)

答案1

这应该有效:

TestMethod((?!TestMethod).)*Requirement((?!TestMethod).)*Requirement

基本上,它使用负向前瞻来检查是否Requirement发生两次,并且它们之间没有任何发生TestMethod

重要的:确保您已. matches newline在 Notepad++ 设置中选中复选框。

相关内容