1

I would like to find out if there are "duplicate" text-fragment between two specific lines.

For example i would like to find out that in the first "TestMethod" there is twice the "TC.Requirement" set.

    [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);
    }

In the first TestMethod there is a doubled Requirement-aatribute, in the second TestMethod there isn't a second.

Could you help me find out the regex for that search?

Thank you :-)

3
  • Have you checked the Notepad++ plugin repository? Do you have Cygwin installed?
    – golimar
    Jun 17, 2013 at 9:05
  • Hi, no Cygwin is not installed. What do I need it for? I am able to search text with Regex, but I am not able to create an appropriate Regex expression to find what I am looking for :-) Jun 18, 2013 at 7:58
  • It's another way of working with text files. But you should try to do it with Regex, perhaps something like this: stackoverflow.com/questions/406230/…
    – golimar
    Jun 18, 2013 at 8:29

1 Answer 1

0

This should work:

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

Basically it uses negative look aheads to check that Requirement occurs twice WITHOUT any occurrence of TestMethod between them.

Important: Make sure that you have the . matches newline checkbox checked in the Notepad++ settings.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .