本文整理匯總了C#中System.Text.RegularExpressions.GroupCollection類的典型用法代碼示例。如果您正苦於以下問題:C# GroupCollection類的具體用法?C# GroupCollection怎麽用?C# GroupCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GroupCollection類屬於System.Text.RegularExpressions命名空間,在下文中一共展示了GroupCollection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestCondition
public static bool TestCondition(string variable, string condition, bool noCase, out GroupCollection groupCollection)
{
groupCollection = null;
// negate condition ?
var negate = false;
if (condition.StartsWith("!")) {
negate = true;
condition = condition.Substring(1);
}
if (condition.StartsWith("=")) {
condition = condition.Substring(1);
return negate ^
String.Equals(variable, condition,
noCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
}
if (condition.StartsWith("<")) {
condition = condition.Substring(1);
return negate ^ String.CompareOrdinal(variable, condition) == -1;
}
if (condition.StartsWith(">")) {
condition = condition.Substring(1);
return negate ^ String.CompareOrdinal(variable, condition) == 1;
}
// otherwise it's a regular expression
var match = Regex.Match(variable, condition, noCase ? RegexOptions.IgnoreCase : RegexOptions.None);
groupCollection = match.Groups;
return negate ^ match.Success;
}
示例2: GetValues
protected virtual IEnumerable<string> GetValues(GroupCollection groups)
{
for (var i = 1; i < groups.Count; i++)
{
yield return groups[i].Value;
}
}
示例3: ExtraVideoMatch
protected override void ExtraVideoMatch(VideoInfo video, GroupCollection matchGroups)
{
TrackingInfo ti = new TrackingInfo();
// for southpark world
System.Text.RegularExpressions.Group epGroup = matchGroups["Episode"];
if (epGroup.Success)
ti.Regex = Regex.Match(epGroup.Value, @"(?<Season>\d\d)(?<Episode>\d\d)");
// for nl and de
if (ti.Season == 0)
ti.Regex = Regex.Match(video.VideoUrl, @"\/S(?<Season>\d{1,3})E(?<Episode>\d{1,3})-", RegexOptions.IgnoreCase);
if (ti.Season != 0)
{
ti.Title = "South Park";
ti.VideoKind = VideoKind.TvSeries;
video.Other = new VideoInfoOtherHelper() { TI = ti };
}
else
video.Other = new VideoInfoOtherHelper();
int time;
if (Int32.TryParse(video.Airdate, out time))
{
video.Airdate = epoch.AddSeconds(time).ToString();
}
}
示例4: SetScorePosition
private void SetScorePosition(IScore score, GroupCollection parts)
{
var offset = string.IsNullOrEmpty(parts[2].Value) ? parts[1].Length : Convert.ToInt32(parts[2].Value);
var timing = parts[1].Value.Last() == '\\' ? OffsetTiming.Early : OffsetTiming.Late;
score.SetPosition(timing == OffsetTiming.Early ? -offset : offset);
}
示例5: AddPeople
private void AddPeople(string groupName, string singular, string plural, StringBuilder sb, GroupCollection groups) {
if (groups[groupName].Success) {
if (sb.Length != 0) sb.AppendLine();
string people=htmlRx.Replace(groups[groupName].Value, string.Empty);
sb.Append(people.Contains(",") ? plural:singular).Append(people);
}
}
示例6: SetStackTraceFilePosition
void SetStackTraceFilePosition(GroupCollection groups)
{
string fileName = groups[1].Value;
int line = Convert.ToInt32(groups[2].Value);
int column = 1;
StackTraceFilePosition = new FilePosition(fileName, line, column);
}
示例7: GetValues
protected override IEnumerable<string> GetValues(GroupCollection groups)
{
for (var i = 1; i < groups.Count; i++)
{
if (groups[i].Success) return new[] {groups[i].Value};
}
return new string[0];
}
示例8: ConvertRegexGroupsToArray
private static string[] ConvertRegexGroupsToArray(GroupCollection groups)
{
var ret = new string[groups.Count - 1];
for (var i = 1; i < groups.Count; i++)
{
ret[i - 1] = groups[i].Value;
}
return ret.Where(x => !String.IsNullOrWhiteSpace(x)).ToArray(); // HACK: This should be changed in the Regex behaviour and this hack should be removed (wait for internet to see the best way)
}
示例9: SelectValue
private int SelectValue( GroupCollection groups, ref string str )
{
int q = 4;
do {
str = groups[ q ].Value;
q += 2;
} while( q <= 8 && str.Length == 0 );
return q - 2;
}
示例10: GetParameters
private static DynamicDictionary GetParameters(Regex regex, GroupCollection groups)
{
dynamic data = new DynamicDictionary();
for (var i = 1; i <= groups.Count; i++)
{
data[regex.GroupNameFromNumber(i)] = groups[i].Value;
}
return data;
}
示例11: GetParameters
private static DynamicDictionary GetParameters(Regex regex, GroupCollection groups)
{
dynamic data = new DynamicDictionary();
for (int i = 1; i <= groups.Count; i++)
{
data[regex.GroupNameFromNumber(i)] = Uri.UnescapeDataString(groups[i].Value);
}
return data;
}
示例12: Match
private Match (Regex regex, IMachine machine,
GroupCollection groups,
string text, int text_length,
int index, int length, int n_caps)
: base (text, index, length, n_caps) {
this.regex = regex;
this.machine = machine;
this.text_length = text_length;
this.groups = groups;
groups.SetValue (this, 0);
}
示例13: AddToList
private void AddToList(GroupCollection groups, List<string> values, string[] ignoreValues)
{
string key = groups["name"].Value;
string value = groups["value"].Value;
if (!String.IsNullOrEmpty(key) && !String.IsNullOrEmpty(value))
{
string valueToAdd = String.Format("{0}={1}", key, HttpUtility.UrlEncode(value));
if (ignoreValues == null || Array.IndexOf(ignoreValues, valueToAdd) == -1)
values.Add(valueToAdd);
}
}
示例14: Add
private void Add(GroupCollection g, string category, IDictionary<string, double> externalDictionary, string success, string fail)
{
var number = g[1].Value;
var unit = g[2].Value;
var wordToAdd = g[3].Value;
var duration = BanTime(number, unit);
if (!category.Contains("Regex")) wordToAdd = wordToAdd.ToLower();
if (Datastore.AddToStateString(category, wordToAdd, duration.TotalSeconds, externalDictionary))
Send(wordToAdd + success);
else
Send(wordToAdd + fail + Tools.PrettyDeltaTime(duration));
}
示例15: DevNamesFrom
private static IEnumerable<string> DevNamesFrom(GroupCollection groups)
{
int skip = 1;
foreach (Group @group in groups)
{
if (skip > 0)
{
skip--;
continue;
}
yield return @group.Value;
}
}