Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 :-)

share|improve this question
    
Have you checked the Notepad++ plugin repository? Do you have Cygwin installed? –  golimar Jun 17 '13 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 :-) –  tedescomicchi Jun 18 '13 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 '13 at 8:29

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.