本文整理汇总了C#中System.Text.RegularExpressions.MatchCollection类的典型用法代码示例。如果您正苦于以下问题:C# MatchCollection类的具体用法?C# MatchCollection怎么用?C# MatchCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MatchCollection类属于System.Text.RegularExpressions命名空间,在下文中一共展示了MatchCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: BuildLinkList
private List<WikiLink> BuildLinkList(PreProcessorContext context, MatchCollection regExLinks)
{
var wikiLinks = (from Match match in regExLinks
select new WikiLink
{
PagePath = CreatePath(context.Page.PagePath, match.Groups[1].Value),
Title = match.Groups[3].Value
}).ToList();
var treeNodes = _repository.Find(wikiLinks.Select(x => x.PagePath).ToList());
foreach (var link in wikiLinks)
{
var node = treeNodes.FirstOrDefault(x => x.Path.Equals(link.PagePath));
if (node != null)
{
if (string.IsNullOrEmpty(link.Title))
link.Title = node.Page.Title;
}
link.Exists = node != null;
}
foreach (var link in wikiLinks)
{
if (string.IsNullOrEmpty(link.Title))
link.Title = link.PagePath.Name;
}
return wikiLinks;
}
开发者ID:jgauffin,项目名称:Griffin.Wiki,代码行数:30,代码来源:WikiLinkProcessor.cs
示例16: regexFun
public static string regexFun(string target, string expr, object g, regexAct ra, string replStr, int replCnt, int replStart, ref MatchCollection o, int capID) {
int gn = g is int ? Int32.Parse(g.ToString()) : 0;
if (capID < 0) { capID = 0; }
Regex regex = new Regex(expr, RegexOptions.Multiline | RegexOptions.IgnoreCase);
try {
switch (ra) {
case regexAct.Match:
var varMatch = regex.Match(target);
if (!varMatch.Success) {
return null;
} else if (g is String && Array.Exists(regex.GetGroupNames(), gpnm => (gpnm == g.ToString()))) {
return varMatch.Groups[g.ToString()].Captures[capID].Value;
} else if (g is int || Int32.TryParse(g.ToString(), out gn)) {
return varMatch.Groups[gn].Captures[capID].Value;
} else {
return varMatch.Groups[0].Captures[capID].Value;
}
case regexAct.Replace:
return regex.Replace(target, (string)replStr, replCnt, replStart);
case regexAct.Matches:
var ms = regex.Matches(target);
o = ms;
return "0";
default:
return "err:-1";
}
} catch{
return "err:-2";
}
}
开发者ID:ingted,项目名称:CLRUDF,代码行数:30,代码来源:REGEX.cs
示例17: AutoGenerateChildren
public void AutoGenerateChildren(MatchCollection matches)
{
int count = 0;
foreach (Match match in matches)
{
m_mon.SetProgress((double) count, (double) matches.Count, Catalog.GetString("Processing Children..."), false);
DegreeMinutes[] coord = Utilities.ParseCoordString(match.Captures[0].Value);
System.Console.WriteLine(Utilities.getCoordString(coord[0], coord[1]));
Waypoint newPoint = new Waypoint ();
Geocache parent = m_mon.SelectedCache;
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_mon.Configuration.IgnoreWaypointPrefixes)
{
name = parent.Name;
}
name = Engine.getInstance().Store.GenerateNewName(name);
newPoint.Name = name;
CacheStore store = Engine.getInstance ().Store;
store.AddWaypointAtomic (newPoint);
count++;
}
}
开发者ID:TweetyHH,项目名称:Open-Cache-Manager,代码行数:28,代码来源:WaypointWidget.cs
示例18: print_r_regex
//Tan solo para ver si el pregmatch tira lo que quiero
public static string print_r_regex(MatchCollection mc)
{
string resp = "";
if(mc.Count > 0)
{
resp += "Printing matches...";
for(int i =0; i < mc.Count; i++)
{
resp += "\n";
resp += "Match["+i+"]: " + mc[i].Value + "\n";
resp += "Printing groups for this match...\n";
GroupCollection gc = mc[i].Groups;
for(int j =0; j < gc.Count; j++)
{
resp += "\tGroup["+j+"]: "+ gc[j].Value + "\n";
resp += "\tPrinting captures for this group...\n";
CaptureCollection cc = gc[j].Captures;
for(int k =0; k < cc.Count; k++)
{
resp += "\t\tCapture["+k+"]: "+ cc[k].Value + "\n";
}
}
}
}
return resp;
}
开发者ID:pay1bux,项目名称:M3U8-Downloader,代码行数:27,代码来源:Utilidades.cs
示例19: WriterHtml
public void WriterHtml(MatchCollection matches)
{
SuccessTotal = matches.Count;
SuccessCurrent = 0;
_strStream.Clear();
_strStream.Append(File.OpenText("HTMLView/index2.txt").ReadToEnd());
foreach (Match match in matches)
{
SuccessCurrent++;
string time = match.Groups[1].Value;
string name = match.Groups[2].Value;
string content = match.Groups[3].Value;
string timeTag = null;
string contentTag = null;
string nameTag = "<span class=\"name\">" + name + "</span>";
bool owner = name == "회원님";
string divClassName = (owner) ? "box box-mine" : "box box-enemy";
_strStream.Append("<div class=\"" + divClassName + "\" >");
_strStream.Append(nameTag);
timeTag = "<span class=\"time\">" + time + "</span>";
if (ImageFiles.ContainsKey(content))
{
string imgPath = "image/" + content;
contentTag = "<a target=\"_blank/\" href=\"" + imgPath + "\" ><img class=\"img\" src=\"" + imgPath + "\"></img></a>";
}
else
{
contentTag = "<p class=\"content\">" + HttpUtility.HtmlEncode(content) + "</p>";
// <br> 등의 Text를 > 화 하기 위함.
}
if (owner)
{
_strStream.Append(timeTag);
_strStream.Append(contentTag);
}
else
{
_strStream.Append(contentTag);
_strStream.Append(timeTag);
}
_strStream.Append("</div>");
}
_strStream.Append("</body></html>");
}
开发者ID:GyuCheol,项目名称:KakaoTrans,代码行数:59,代码来源:TransferLogic2.cs
示例20: TextHighlighter
public TextHighlighter(
Page page,
MatchCollection matches
)
{
this.page = page;
this.matchEnumerator = matches.GetEnumerator();
}
开发者ID:n9,项目名称:pdfclown,代码行数:8,代码来源:TextHighlightSample.cs
注:本文中的System.Text.RegularExpressions.MatchCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论