当前位置: 首页>>代码示例>>C#>>正文


C# RegularExpressions.MatchCollection类代码示例

本文整理汇总了C#中System.Text.RegularExpressions.MatchCollection的典型用法代码示例。如果您正苦于以下问题:C# MatchCollection类的具体用法?C# MatchCollection怎么用?C# MatchCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MatchCollection类属于System.Text.RegularExpressions命名空间,在下文中一共展示了MatchCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildAwardCache

        /// <summary>
        /// This method builds the award cache with the given data from the medal data file.
        /// This method WILL CLEAR the award cache from any existing medals
        /// </summary>
        /// <param name="MedalsMatches"></param>
        /// <param name="RanksMatches"></param>
        public static void BuildAwardCache(MatchCollection MedalsMatches, MatchCollection RanksMatches)
        {
            // Clear out the award cache!
            AwardCache.Clear();

            // Convert each medal match into an object, and add it to the award cache
            foreach (Match ArrayMatch in MedalsMatches)
            {
                AwardCache.AddAward(
                    new Award(
                        ArrayMatch.Groups["MedalIntId"].Value,
                        ArrayMatch.Groups["MedalStrId"].Value,
                        ArrayMatch.Groups["RewardType"].Value,
                        ParseCondition(ArrayMatch.Groups["Conditions"].Value)
                    )
                );
            }

            // Convert ranks into objects, and also add them to the award cache
            foreach (Match ArrayMatch in RanksMatches)
            {
                AwardCache.AddRank(
                    new Rank(
                        Int32.Parse(ArrayMatch.Groups["RankId"].Value),
                        ParseCondition(ArrayMatch.Groups["Conditions"].Value)
                    )
                );
            }
        }
开发者ID:JohannesHei,项目名称:ControlCenter,代码行数:35,代码来源:MedalDataParser.cs

示例2: FindLongestConsecutivePair

        private static string[] FindLongestConsecutivePair(MatchCollection usernames)
        {
            int bestLength = 0,
                fromIndex = 0;

            if (usernames.Count == 1)
            {
                Console.WriteLine(usernames[0].Value);

                return new string[]
                {
                    usernames[0].Value
                };
            }

            for (int i = 1; i < usernames.Count; i++)
            {
                string current = usernames[i].Value,
                    prev = usernames[i - 1].Value;

                int currentLength = current.Length + prev.Length;

                if (currentLength > bestLength)
                {
                    bestLength = currentLength;
                    fromIndex = i - 1;
                }
            }

            return new string[]
            {
                usernames[fromIndex].Value,
                usernames[fromIndex + 1].Value
            };
        }
开发者ID:kidroca,项目名称:Advanced-CSharp-2015,代码行数:35,代码来源:ValidUsrname.cs

示例3: RecursiveFindDynamicClause

        public string RecursiveFindDynamicClause(MatchCollection matchs, SqlCommand sqlCommand)
        {
            string result = string.Empty;
            if (matchs.Count < 1)
                return result;

            foreach (Match match in matchs)
            {
                result = match.Value;
                string reResult = RecursiveFindDynamicClause(RegexPattern.DynamicClausePattern.Matches(match.Groups["DynamicClause"].Value), sqlCommand);
                if (!sqlCommand.Parameters.Exists((c) =>
                {
                    bool r = false;
                    string tempResult = string.IsNullOrEmpty(reResult) ? result : result.Replace(reResult, "");
                    if (SqlUtil.ContainsParameterName(tempResult, c.ParameterName))
                    {
                        //当值不为“null”、“DBNull”和“空白字符串”时参数值才算是有效
                        if (c.Value != null && c.Value != DBNull.Value && c.Value.ToString().Trim() != string.Empty)
                        {
                            r = true;
                        }

                        if (result.StartsWith(LEFT_BRACE_DUBLE_QUESTION_MARK))
                        {
                            r = true;
                        }
                    }
                    return r;
                }))
                {
                    removeClauseStack.Push(result);
                }
            }
            return result;
        }
开发者ID:JackWangCUMT,项目名称:Zhuang.Data,代码行数:35,代码来源:DynamicClauseParser.cs

示例4: BatchInsertIncidentCollections

        public int BatchInsertIncidentCollections(MatchCollection collections, ConfigInitializer.IncidentTableEntity incidentTable, out HashSet<string> duplicateHash, bool SKIP)
        {
            duplicateHash = new HashSet<string>();
            if (SKIP) return 0;

            var queryText = incidentTable.ToString();
            var incident = new DataNormalizer.DataEntity.Incident(incidentTable);
            int successCount = 0;
            //var queryText = $"INSERT into {this.tableInfo.tableName} {this.tableInfo.queryItemPattern} VALUES {this.tableInfo.queryValuePattern}";
            using (var transaction = this._connection.BeginTransaction())
            {
                foreach (Match match in collections)
                {
                    var cmd = new SqlCommand(queryText, this._connection, transaction);
                    incident.registerSqlCommand(match, ref cmd);
                    try
                    {
                        cmd.ExecuteNonQuery();
                        Console.WriteLine($"Insert: {match.Groups[1].Value}");
                        successCount += 1;
                    }
                    catch
                    {
                        var incidentString = match.Groups[1].Value;
                        duplicateHash.Add(incidentString);
                        Console.WriteLine($"Duplicate Incident: {incidentString}");
                    }
                }
                transaction.Commit();
            }
            return successCount;
        }
开发者ID:yeze322,项目名称:CorpusDBWriter,代码行数:32,代码来源:DBController.cs

示例5: Matched

        public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
        {
            foreach (Match m in matches) {

                MySqlCommand cleanup = new MySqlCommand(@"DELETE FROM techtree_useritems
            USING (" + DBPrefix + @"techtree_useritems AS techtree_useritems) INNER JOIN (" + DBPrefix + @"techtree_items AS techtree_items) ON techtree_items.ID=techtree_useritems.itemid
            WHERE techtree_useritems.uid=?uid AND techtree_items.type = 'for'", con);
                cleanup.Parameters.Add("?uid", MySqlDbType.UInt32).Value = victimID;
                cleanup.Prepare();
                cleanup.ExecuteNonQuery();

                String[] parts = m.Groups[1].Value.Split('\n');
                MySqlCommand idQry = new MySqlCommand(@"SELECT ID FROM " + DBPrefix + @"techtree_items WHERE Name=?name", con);
                idQry.Parameters.Add("?name", MySqlDbType.String);
                idQry.Prepare();

                MySqlCommand idInsert = new MySqlCommand(@"INSERT IGNORE INTO " + DBPrefix + @"techtree_useritems (uid, itemid, count) VALUES (?uid, ?itemid, 1)", con);
                idInsert.Parameters.Add("?uid", MySqlDbType.UInt32).Value = victimID;
                idInsert.Parameters.Add("?itemid", MySqlDbType.UInt32);
                idInsert.Prepare();

                foreach (String forschung in parts) {
                    idQry.Parameters["?name"].Value = forschung;
                    object res = idQry.ExecuteScalar();
                    if (res == null)
                        continue;
                    uint id = (uint)res;
                    idInsert.Parameters["?itemid"].Value = id;
                    idInsert.ExecuteNonQuery();
                }
            }
            resp.Respond("Forschungsübersicht eingelesen!");
        }
开发者ID:Grollicus,项目名称:iwdb,代码行数:33,代码来源:TechTree.cs

示例6: CreateCollection

 private static IHtmlCollection CreateCollection(MatchCollection matches)
 {
     var elements = new List<IHtmlElement>();
     foreach (Match match in matches)
         elements.Add(CreateElement(match));
     return new HtmlCollection(elements);
 }
开发者ID:mhenry07,项目名称:ASPUnitRunner,代码行数:7,代码来源:HtmlElementParser.cs

示例7: getLinkList

 private List<Link> getLinkList(MatchCollection matches)
 {
     List<Link> links = new List<Link>();
     for (int i = 0; i < matches.Count; i++)
         addLink(i, matches, links);
     return links;
 }
开发者ID:Vernathic,项目名称:ic-AutoTest.NET4CTDD,代码行数:7,代码来源:LinkParser.cs

示例8: Matched

 public override void Matched(MatchCollection matches, uint posterID, uint victimID, DateTime now, MySqlConnection con, SingleNewscanRequestHandler handler, ParserResponse resp)
 {
     Dictionary<uint, String> uidToIgmNameCache = new Dictionary<uint, string>();
     foreach(Match outerMatch in matches) {
         String empfaenger;
         if(!uidToIgmNameCache.TryGetValue(victimID, out empfaenger)) {
             MySqlCommand igmNameQry = new MySqlCommand("SELECT igmname FROM " + DBPrefix + "igm_data WHERE id=?igmid", con);
             igmNameQry.Parameters.Add("?igmid", MySqlDbType.UInt32).Value = victimID;
             Object obj = igmNameQry.ExecuteScalar();
             empfaenger = (String)obj;
             uidToIgmNameCache.Add(victimID, empfaenger);
         }
         Transport t = new Transport(
             uint.Parse(outerMatch.Groups[1].Value),
             uint.Parse(outerMatch.Groups[2].Value),
             uint.Parse(outerMatch.Groups[3].Value),
             empfaenger,
             outerMatch.Groups[5].Value,
             IWDBUtils.parsePreciseIWTime(outerMatch.Groups[4].Value)
         );
         MatchCollection c = Regex.Matches(outerMatch.Groups[7].Value, @"\s(" + RessourcenName + @")\s+(" + Number + ")");
         foreach(Match m in c) {
             t.SetRess(m.Groups[1].Value, int.Parse(m.Groups[2].Value, System.Globalization.NumberStyles.Any));
         }
         t.ToDB(con, DBPrefix, handler.BesData, resp, "Übergabebericht");
     }
 }
开发者ID:Grollicus,项目名称:iwdb,代码行数:27,代码来源:Transportberichte.cs

示例9: getVulnerablePages

		private void getVulnerablePages(MatchCollection mirrors) {
			foreach (var pageUrl in mirrors) {
				string data = tryGetUrlData(BASE_URL + pageUrl);
				extractUrl(data);
				extractAndSaveHtmlPage(data);
			}
		}
开发者ID:techbossmb,项目名称:xssed_crawler,代码行数:7,代码来源:XssCrawler.cs

示例10: ParseMeters

 private void ParseMeters(MatchCollection matches)
 {
     string metersString = matches[1].Groups[0].Value.Trim();
     string[] arrayMeters = metersString.Split(new char[] { ' ' });
     string meterValue = arrayMeters[0];
     meters = double.Parse(meterValue);
 }
开发者ID:reddream,项目名称:length,代码行数:7,代码来源:UnitParser.cs

示例11: cleanLinks

        private static Collection<LinkItem> cleanLinks(MatchCollection m1)
        {
            Collection<LinkItem> list = new Collection<LinkItem>();

            // 2.
            // Loop over each match.
            foreach (Match m in m1)
            {
                string value = m.Groups[1].Value;

                // 3.
                // Get href attribute.
                Match m2 = Regex.Match(value, @"href=\""(.*?)\""",
                RegexOptions.Singleline);
                if (m2.Success)
                {
                    LinkItem i = new LinkItem();
                    i.Href = m2.Groups[1].Value;

                    // 4.
                    // Remove inner tags from text and add.
                    string t = Regex.Replace(value, @"\s*<.*?>\s*", "",
                    RegexOptions.Singleline);
                    i.Text = t;

                    list.Add(i);
                }
            }
            return list;
        }
开发者ID:jacron,项目名称:ClipboardTool,代码行数:30,代码来源:GetLinks.cs

示例12: cleanLinks2

        private static Collection<LinkItem> cleanLinks2(MatchCollection m1)
        {
            Collection<LinkItem> list = new Collection<LinkItem>();

            // 2.
            // Loop over each match.
            foreach (Match m in m1)
            {
                string value = m.Groups[1].Value;
                LinkItem i = new LinkItem();
                int pos = value.IndexOf(' ');
                if (pos == -1)
                {
                    pos = value.IndexOf('\n');
                }
                if (pos == -1)
                {
                    pos = value.IndexOf('\t');
                }
                if (pos != -1)
                {
                    value = value.Substring(0, pos);
                }
                pos = value.IndexOf('<');
                if (pos != -1)
                {
                    value = value.Substring(0, pos);
                }
                i.Href = value;
                list.Add(i);

            }
            return list;
        }
开发者ID:jacron,项目名称:ClipboardTool,代码行数:34,代码来源:GetLinks.cs

示例13: Extract

        /// <summary>
        /// Extracts the matches of this pattern from <paramref name="source" />.
        /// </summary>
        /// <param name="fileName">The name of the file associated with <paramref name="source" />.</param>
        /// <param name="source">The source string</param>
        /// <returns>
        /// A collection of found matches.
        /// </returns>
        public MatchCollection Extract(string fileName, string source)
        {
            MatchCollection resultMatches = new MatchCollection();
            LineCounter lineCounter = new LineCounter(source);

            RegexMatch regexMatch = scanner.Match(source);
            while (regexMatch.Success)
            {
                Match match = new Match();
                match["Path"] = Path.GetDirectoryName(fileName);
                match["File"] = Path.GetFileName(fileName);
                match["LineNumber"] = lineCounter.CountTo(regexMatch.Index).InvariantToString();
                foreach (string groupName in scanner.GetGroupNames())
                {
                    // ignore default-names like '0', '1' ... as produced
                    // by the Regex class
                    if (Char.IsLetter(groupName[0]) || (groupName[0] == '_'))
                    {
                        match[groupName] = ConcatenateCaptures(regexMatch.Groups[groupName]);
                    }
                }
                resultMatches.Add(match);
                regexMatch = regexMatch.NextMatch();
            }
            return resultMatches;
        }
开发者ID:scottdorman,项目名称:MSBuildContrib,代码行数:34,代码来源:Pattern.cs

示例14: AutoGenerateChildren

        public void AutoGenerateChildren(MatchCollection matches)
        {
            int count = 0;
            m_App.CacheStore.StartUpdate();
            foreach (Match match in matches)
            {
                DegreeMinutes[] coord = Utilities.ParseCoordString (match.Captures[0].Value);
                System.Console.WriteLine (Utilities.getCoordString (coord[0], coord[1]));

                Waypoint newPoint = new Waypoint ();
                Geocache parent = m_Cache;
                newPoint.Symbol = "Reference Point";
                newPoint.Parent = parent.Name;
                newPoint.Lat = coord[0].GetDecimalDegrees ();
                newPoint.Lon = coord[1].GetDecimalDegrees ();
                newPoint.Desc = Catalog.GetString ("Grabbed Waypoint");
                String name = "RP" + parent.Name.Substring (2);
                if (m_App.AppConfig.IgnoreWaypointPrefixes)
                {
                    name = parent.Name;
                }
                name = m_App.CacheStore.GetUniqueName(name);
                newPoint.Name = name;
                m_App.CacheStore.AddWaypointOrCache(newPoint, false, false);
                count++;
            }
            m_App.CacheStore.CompleteUpdate();
            m_App.RefreshAll();
        }
开发者ID:cbuehler,项目名称:opencachemanager,代码行数:29,代码来源:WaypointWidget.cs

示例15: RegExpMatch

 internal RegExpMatch(ArrayPrototype parent, Regex regex, Match match, string input) : base(parent, typeof(RegExpMatch))
 {
     this.hydrated = false;
     this.regex = regex;
     this.matches = null;
     this.match = match;
     base.SetMemberValue("input", input);
     base.SetMemberValue("index", match.Index);
     base.SetMemberValue("lastIndex", (match.Length == 0) ? (match.Index + 1) : (match.Index + match.Length));
     string[] groupNames = regex.GetGroupNames();
     int num = 0;
     for (int i = 1; i < groupNames.Length; i++)
     {
         string name = groupNames[i];
         int num3 = regex.GroupNumberFromName(name);
         if (name.Equals(num3.ToString(CultureInfo.InvariantCulture)))
         {
             if (num3 > num)
             {
                 num = num3;
             }
         }
         else
         {
             Group group = match.Groups[name];
             base.SetMemberValue(name, group.Success ? group.ToString() : null);
         }
     }
     this.length = num + 1;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:RegExpMatch.cs


注:本文中的System.Text.RegularExpressions.MatchCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。