本文整理汇总了C#中IronRuby.Builtins.MatchData类的典型用法代码示例。如果您正苦于以下问题:C# MatchData类的具体用法?C# MatchData怎么用?C# MatchData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MatchData类属于IronRuby.Builtins命名空间,在下文中一共展示了MatchData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGroup
public static RubyArray GetGroup(ConversionStorage<int>/*!*/ fixnumCast, MatchData/*!*/ self, [NotNull]Range/*!*/ range) {
int begin, count;
if (!IListOps.NormalizeRange(fixnumCast, self.Groups.Count, range, out begin, out count)) {
return null;
}
return GetGroup(fixnumCast.Context, self, begin, count);
}
示例2: GetGroup
public static RubyArray GetGroup(RubyContext/*!*/ context, MatchData/*!*/ self, [NotNull]Range/*!*/ range) {
int begin, count;
if (!IListOps.NormalizeRange(context, self.Groups.Count, range, out begin, out count)) {
return null;
}
return GetGroup(context, self, begin, count);
}
示例3: Offset
public static RubyArray/*!*/ Offset(MatchData/*!*/ self, [DefaultProtocol]int groupIndex) {
var group = self.GetExistingGroup(groupIndex);
RubyArray result = new RubyArray(2);
if (group.Success) {
result.Add(group.Index);
result.Add(group.Index + group.Length);
} else {
result.Add(null);
result.Add(null);
}
return result;
}
示例4: Offset
public static RubyArray/*!*/ Offset(MatchData/*!*/ self, [DefaultProtocol]int groupIndex) {
self.RequireExistingGroup(groupIndex);
RubyArray result = new RubyArray(2);
if (self.GroupSuccess(groupIndex)) {
result.Add(self.GetGroupStart(groupIndex));
result.Add(self.GetGroupEnd(groupIndex));
} else {
result.Add(null);
result.Add(null);
}
return result;
}
示例5: PreMatch
public static MutableString/*!*/ PreMatch(RubyContext/*!*/ context, MatchData/*!*/ self) {
return self.OriginalString.GetSlice(0, self.Index).TaintBy(self, context);
}
示例6: Captures
public static RubyArray/*!*/ Captures(RubyContext/*!*/ context, MatchData/*!*/ self) {
return ReturnMatchingGroups(context, self, 1);
}
示例7: MatchToScanResult
private static object MatchToScanResult(RubyScope/*!*/ scope, MutableString/*!*/ self, RubyRegex/*!*/ regex, MatchData/*!*/ match) {
if (match.GroupCount == 1) {
return match.GetValue().TaintBy(regex, scope);
} else {
var result = new RubyArray(match.GroupCount - 1);
for (int i = 1; i < match.GroupCount; i++) {
MutableString value = match.GetGroupValue(i);
result.Add(value != null ? value.TaintBy(regex, scope) : value);
}
return result;
}
}
示例8: AppendLastCharOfLastMatchGroup
private static void AppendLastCharOfLastMatchGroup(MatchData/*!*/ match, MutableString/*!*/ result) {
int i = match.GroupCount - 1;
// move to last successful match group
while (i > 0 && !match.GroupSuccess(i)) {
i--;
}
if (i > 0 && match.GroupSuccess(i)) {
int length = match.GetGroupLength(i);
if (length > 0) {
result.Append(match.OriginalString, match.GetGroupStart(i) + length - 1, 1);
}
}
}
示例9: InitializeCopy
public static MatchData/*!*/ InitializeCopy(MatchData/*!*/ self, [NotNull]MatchData/*!*/ other) {
self.InitializeFrom(other);
return self;
}
示例10: ToS
public static MutableString/*!*/ ToS(RubyContext/*!*/ context, MatchData/*!*/ self) {
return MutableString.Create(self.Value).TaintBy(self, context);
}
示例11: Inspect
public static MutableString/*!*/ Inspect(RubyContext/*!*/ context, MatchData/*!*/ self) {
return RubyUtils.ObjectToMutableString(context, self);
}
示例12: ValuesAt
public static RubyArray/*!*/ ValuesAt(ConversionStorage<int>/*!*/ conversionStorage,
MatchData/*!*/ self, [DefaultProtocol, NotNull]params int[]/*!*/ indices) {
RubyArray result = new RubyArray();
for (int i = 0; i < indices.Length; i++) {
result.Add(GetGroup(conversionStorage.Context, self, indices[i]));
}
return result;
}
示例13: Select
public static object Select(RubyContext/*!*/ context, [NotNull]BlockParam/*!*/ block, MatchData/*!*/ self) {
RubyArray result = new RubyArray();
for (int i = 0; i < self.Groups.Count; i++) {
MutableString value = self.GetGroupValue(context, i);
object blockResult;
if (block.Yield(value, out blockResult)) {
return blockResult;
}
if (RubyOps.IsTrue(blockResult)) {
result.Add(value);
}
}
return result;
}
示例14: ReturnFrozenString
public static MutableString/*!*/ ReturnFrozenString(RubyContext/*!*/ context, MatchData/*!*/ self) {
return MutableString.Create(self.OriginalString).TaintBy(self, context).Freeze();
}
示例15: ToArray
public static RubyArray/*!*/ ToArray(RubyContext/*!*/ context, MatchData/*!*/ self) {
return ReturnMatchingGroups(context, self, 0);
}