Click here to Skip to main content
15,885,951 members
Articles / Programming Languages / XML

.NET Regular Expressions Find and Replace Add-In for Visual Studio 2008

Rate me:
Please Sign up or sign in to vote.
4.91/5 (36 votes)
12 Oct 2009CPOL3 min read 185.3K   1.6K   117  
A .NET Regular Expressions Find and Replace add-in for Visual Studio 2008
using System;

namespace RegexFindAndReplace
{
    /// <summary>
    /// Finds the next match.
    /// </summary>
    /// <param name="finderAndReplacer">The FinderAndReplacer.</param>
    public class FirstFindSucceededAndBackToStartPointState : IFindState
    {
        public void FindNext( FinderAndReplacer finderAndReplacer )
        {
            if ( finderAndReplacer.AttemptMatch() )
            {
                if ( finderAndReplacer.WrappedToStartPoint() )
                {
                    finderAndReplacer.SetState( new FirstFindState() );
                    finderAndReplacer.ResetLatestFindStartPosition();
                    finderAndReplacer.ShowMessage( "Passed the end of the document.", true );
                }
                else
                {
                    finderAndReplacer.SelectMatchedText();
                }
            }
            else
            {
                finderAndReplacer.ResetLatestFindStartPosition();
                finderAndReplacer.SetState( new FirstFindState() );
                finderAndReplacer.ShowMessage( "Passed the end of the document.", true );
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I am a software developer currently working in Salt Lake City, Utah. I work primarily with C# for my job, but I mess around with C, Perl, and Windows PowerShell for fun.

Comments and Discussions