146 lines
4.9 KiB
C#
146 lines
4.9 KiB
C#
using System;
|
|
|
|
namespace System.Text.RegularExpressions
|
|
{
|
|
/// <summary>Represents the results from a single regular expression match.</summary>
|
|
// Token: 0x020002AF RID: 687
|
|
[Serializable]
|
|
public class Match : Group
|
|
{
|
|
// Token: 0x0600190F RID: 6415 RVA: 0x00055C30 File Offset: 0x00053E30
|
|
private Match()
|
|
{
|
|
this.regex = null;
|
|
this.machine = null;
|
|
this.text_length = 0;
|
|
this.groups = new GroupCollection(1, 1);
|
|
this.groups.SetValue(this, 0);
|
|
}
|
|
|
|
// Token: 0x06001910 RID: 6416 RVA: 0x00055C68 File Offset: 0x00053E68
|
|
internal Match(Regex regex, IMachine machine, string text, int text_length, int n_groups, int index, int length)
|
|
: base(text, index, length)
|
|
{
|
|
this.regex = regex;
|
|
this.machine = machine;
|
|
this.text_length = text_length;
|
|
}
|
|
|
|
// Token: 0x06001911 RID: 6417 RVA: 0x00055C8C File Offset: 0x00053E8C
|
|
internal Match(Regex regex, IMachine machine, string text, int text_length, int n_groups, 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 = new GroupCollection(n_groups, regex.Gap);
|
|
this.groups.SetValue(this, 0);
|
|
}
|
|
|
|
/// <summary>Gets the empty group. All failed matches return this empty match.</summary>
|
|
/// <returns>An empty <see cref="T:System.Text.RegularExpressions.Match" />.</returns>
|
|
// Token: 0x170007DE RID: 2014
|
|
// (get) Token: 0x06001913 RID: 6419 RVA: 0x00055CE8 File Offset: 0x00053EE8
|
|
public static Match Empty
|
|
{
|
|
get
|
|
{
|
|
return Match.empty;
|
|
}
|
|
}
|
|
|
|
/// <summary>Returns a <see cref="T:System.Text.RegularExpressions.Match" /> instance equivalent to the one supplied that is suitable to share between multiple threads.</summary>
|
|
/// <returns>A match that is suitable to share between multiple threads.</returns>
|
|
/// <param name="inner">A match equivalent to the one expected.</param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="inner" /> is null.</exception>
|
|
// Token: 0x06001914 RID: 6420 RVA: 0x00055CF0 File Offset: 0x00053EF0
|
|
[global::System.MonoTODO("not thread-safe")]
|
|
public static Match Synchronized(Match inner)
|
|
{
|
|
if (inner == null)
|
|
{
|
|
throw new ArgumentNullException("inner");
|
|
}
|
|
return inner;
|
|
}
|
|
|
|
/// <summary>Gets a collection of groups matched by the regular expression.</summary>
|
|
/// <returns>The character groups matched by the pattern.</returns>
|
|
// Token: 0x170007DF RID: 2015
|
|
// (get) Token: 0x06001915 RID: 6421 RVA: 0x00055D04 File Offset: 0x00053F04
|
|
public virtual GroupCollection Groups
|
|
{
|
|
get
|
|
{
|
|
return this.groups;
|
|
}
|
|
}
|
|
|
|
/// <summary>Returns a new <see cref="T:System.Text.RegularExpressions.Match" /> object with the results for the next match, starting at the position at which the last match ended (at the character after the last matched character).</summary>
|
|
/// <returns>The next regular expression match.</returns>
|
|
/// <PermissionSet>
|
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
|
/// </PermissionSet>
|
|
// Token: 0x06001916 RID: 6422 RVA: 0x00055D0C File Offset: 0x00053F0C
|
|
public Match NextMatch()
|
|
{
|
|
if (this == Match.Empty)
|
|
{
|
|
return Match.Empty;
|
|
}
|
|
int num = ((!this.regex.RightToLeft) ? (base.Index + base.Length) : base.Index);
|
|
if (base.Length == 0)
|
|
{
|
|
num += ((!this.regex.RightToLeft) ? 1 : (-1));
|
|
}
|
|
return this.machine.Scan(this.regex, base.Text, num, this.text_length);
|
|
}
|
|
|
|
/// <summary>Returns the expansion of the specified replacement pattern. </summary>
|
|
/// <returns>The expanded version of the <paramref name="replacement" /> parameter.</returns>
|
|
/// <param name="replacement">The replacement pattern to use. </param>
|
|
/// <exception cref="T:System.ArgumentNullException">
|
|
/// <paramref name="replacement" /> is null.</exception>
|
|
/// <exception cref="T:System.NotSupportedException">Expansion is not allowed for this pattern.</exception>
|
|
// Token: 0x06001917 RID: 6423 RVA: 0x00055D98 File Offset: 0x00053F98
|
|
public virtual string Result(string replacement)
|
|
{
|
|
if (replacement == null)
|
|
{
|
|
throw new ArgumentNullException("replacement");
|
|
}
|
|
if (this.machine == null)
|
|
{
|
|
throw new NotSupportedException("Result cannot be called on failed Match.");
|
|
}
|
|
return this.machine.Result(replacement, this);
|
|
}
|
|
|
|
// Token: 0x170007E0 RID: 2016
|
|
// (get) Token: 0x06001918 RID: 6424 RVA: 0x00055DDC File Offset: 0x00053FDC
|
|
internal Regex Regex
|
|
{
|
|
get
|
|
{
|
|
return this.regex;
|
|
}
|
|
}
|
|
|
|
// Token: 0x040013CB RID: 5067
|
|
private Regex regex;
|
|
|
|
// Token: 0x040013CC RID: 5068
|
|
private IMachine machine;
|
|
|
|
// Token: 0x040013CD RID: 5069
|
|
private int text_length;
|
|
|
|
// Token: 0x040013CE RID: 5070
|
|
private GroupCollection groups;
|
|
|
|
// Token: 0x040013CF RID: 5071
|
|
private static Match empty = new Match();
|
|
}
|
|
}
|