Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Visual Studio Add-in for testing regular expressions

, 1 Dec 2010 CPOL
An add-in for debugging and creating regular expression directly in Visual Studio
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom;
using System.CodeDom.Compiler;
using RegexTester.Parsing;
using RegexTester.Parsing.CSharp;

namespace RegexTester
{
    public class RegexFinder
    {
        private IRegexFormatProvider formatProvider;

        public RegexFinder(IRegexFormatProvider formatProvider)
        {
            this.formatProvider = formatProvider;
        }

        public RegexFinder()
            : this(new CSharpRegexFormatProvider())
        {
        }

        public IRegexFindResults FindRegex(string text)
        {
            Regex matchSyntaxRegex = formatProvider.GetSyntaxRegex();
            Match foundMatch = matchSyntaxRegex.Match(text);

            return formatProvider.GetRegexFindResults(foundMatch);
        }
    }

    public interface IRegexFindResults
    {
        bool FoundMatch { get; }
        bool IsMatchOnlyRegex { get; }
        string ToMatch { get; set; }
        string ToMatchExpression { get; }
        string ReplacePattern { get; set; }
        string Regex { get; set; }
        RegexOptions RegexOptions { get; set; }
        bool IsEdit { get; }
        int Index { get; }
        int Length { get; }
        void ConvertToEdit();
        void ConvertToDisplay();
        string GetRegexString();
    }
}

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)

Share

About the Author

Andreas Andersen
Software Developer (Senior)
Denmark Denmark
.NET developer. I wanted to be first an astronaut, then a jet pilot, but when I got a Commodore 64 for Christmas I never looked back. Also I would never have qualified for the first two things and everybody knows computer programmers get all the girls.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150129.1 | Last Updated 1 Dec 2010
Article Copyright 2010 by Andreas Andersen
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid