예제 #1
0
        public static List <List <string> > Parse(string Source, string Regex, bool SingleLine = true)
        {
            List <List <string> > Result = new List <List <string> >();

            Regex MainRegex;

            if (SingleLine)
            {
                MainRegex = new Regex(Regex);
            }
            else
            {
                MainRegex = new Regex(Regex, RegexOptions.Multiline);
            }

            MatchCollection RegexMatches = MainRegex.Matches(Source);

            int RegexMatchCount = RegexMatches.Count;

            for (int i = 0; i < RegexMatchCount; ++i)
            {
                Result.Add(new List <string>());

                var PositionGroups = RegexMatches[i].Groups;
                int PositionCount  = PositionGroups.Count;

                for (int k = 1; k < PositionCount + 1; ++k)
                {
                    Result[i].Add(PositionGroups[k].Value);
                }
            }

            return(Result);
        }
예제 #2
0
        public static bool Contains(string Source, string Regex, bool SingleLine = true)
        {
            Regex MainRegex;

            if (SingleLine)
            {
                MainRegex = new Regex(Regex);
            }
            else
            {
                MainRegex = new Regex(Regex, RegexOptions.Multiline);
            }

            MatchCollection RegexMatches = MainRegex.Matches(Source);

            if (RegexMatches.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }