using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.Serialization;
using System.Text.RegularExpressions.Syntax;
namespace System.Text.RegularExpressions
{
/// Represents an immutable regular expression.
// Token: 0x020002B2 RID: 690
[Serializable]
public class Regex : ISerializable
{
/// Initializes a new instance of the class.
// Token: 0x06001927 RID: 6439 RVA: 0x000560CC File Offset: 0x000542CC
protected Regex()
{
}
/// Initializes and compiles a new instance of the class for the specified regular expression.
/// The regular expression pattern to match.
/// A regular expression parsing error has occurred.
///
/// is null.
// Token: 0x06001928 RID: 6440 RVA: 0x000560D4 File Offset: 0x000542D4
public Regex(string pattern)
: this(pattern, RegexOptions.None)
{
}
/// Initializes and compiles a new instance of the class for the specified regular expression, with options that modify the pattern.
/// The regular expression pattern to match.
/// A bitwise OR combination of the enumeration values.
/// A regular expression parsing error has occurred.
///
/// is null.
///
/// contains an invalid flag.
// Token: 0x06001929 RID: 6441 RVA: 0x000560E0 File Offset: 0x000542E0
public Regex(string pattern, RegexOptions options)
{
if (pattern == null)
{
throw new ArgumentNullException("pattern");
}
Regex.validate_options(options);
this.pattern = pattern;
this.roptions = options;
this.Init();
}
/// Initializes a new instance of the class using serialized data.
/// The object that contains a serialized pattern and information.
/// The destination for this serialization. (This parameter is not used; specify null.)
/// A regular expression parsing error has occurred.
/// The pattern that contains is null.
///
/// contains an invalid flag.
// Token: 0x0600192A RID: 6442 RVA: 0x00056114 File Offset: 0x00054314
protected Regex(SerializationInfo info, StreamingContext context)
: this(info.GetString("pattern"), (RegexOptions)((int)info.GetValue("options", typeof(RegexOptions))))
{
}
/// Populates a object with the data necessary to deserialize the current object.
/// The object to populate with serialization information.
/// The place to store and retrieve serialized data. Reserved for future use.
// Token: 0x0600192C RID: 6444 RVA: 0x0005615C File Offset: 0x0005435C
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("pattern", this.ToString(), typeof(string));
info.AddValue("options", this.Options, typeof(RegexOptions));
}
/// Compiles one or more specified objects to a named file.
/// An array that describes the regular expressions to compile.
/// The file name of the assembly.
/// The value of the parameter's property is an empty or null string.-or-The regular expression pattern of one or more objects in contains invalid syntax.
///
/// or is null.
///
///
///
///
// Token: 0x0600192D RID: 6445 RVA: 0x000561A4 File Offset: 0x000543A4
[global::System.MonoTODO]
public static void CompileToAssembly(RegexCompilationInfo[] regexes, AssemblyName aname)
{
Regex.CompileToAssembly(regexes, aname, new CustomAttributeBuilder[0], null);
}
/// Compiles one or more specified objects to a named file with specified attributes.
/// An array that describes the regular expressions to compile.
/// The file name of the assembly.
/// An array that defines the attributes to apply to the assembly.
/// The value of the parameter's property is an empty or null string.-or-The regular expression pattern of one or more objects in contains invalid syntax.
///
/// or is null.
///
///
///
///
// Token: 0x0600192E RID: 6446 RVA: 0x000561B4 File Offset: 0x000543B4
[global::System.MonoTODO]
public static void CompileToAssembly(RegexCompilationInfo[] regexes, AssemblyName aname, CustomAttributeBuilder[] attribs)
{
Regex.CompileToAssembly(regexes, aname, attribs, null);
}
/// Compiles one or more specified objects and a specified resource file to a named assembly with specified attributes.
/// An array that describes the regular expressions to compile.
/// The file name of the assembly.
/// An array that defines the attributes to apply to the assembly.
/// The name of the Win32 resource file to include in the assembly.
/// The value of the parameter's property is an empty or null string.-or-The regular expression pattern of one or more objects in contains invalid syntax.
///
/// or is null.
/// The parameter designates an invalid Win32 resource file.
/// The file designated by the parameter cannot be found.
///
///
///
///
// Token: 0x0600192F RID: 6447 RVA: 0x000561C0 File Offset: 0x000543C0
[global::System.MonoTODO]
public static void CompileToAssembly(RegexCompilationInfo[] regexes, AssemblyName aname, CustomAttributeBuilder[] attribs, string resourceFile)
{
throw new NotImplementedException();
}
/// Escapes a minimal set of characters (\, *, +, ?, |, {, [, (,), ^, $,., #, and white space) by replacing them with their escape codes. This instructs the regular expression engine to interpret these characters literally rather than as metacharacters.
/// A string of characters with metacharacters converted to their escaped form.
/// The input string containing the text to convert.
///
/// is null.
// Token: 0x06001930 RID: 6448 RVA: 0x000561C8 File Offset: 0x000543C8
public static string Escape(string str)
{
if (str == null)
{
throw new ArgumentNullException("str");
}
return global::System.Text.RegularExpressions.Syntax.Parser.Escape(str);
}
/// Converts any escaped characters in the input string.
/// A string of characters with any escaped characters converted to their unescaped form.
/// The input string containing the text to convert.
///
/// includes an unrecognized escape sequence.
///
/// is null.
// Token: 0x06001931 RID: 6449 RVA: 0x000561E4 File Offset: 0x000543E4
public static string Unescape(string str)
{
if (str == null)
{
throw new ArgumentNullException("str");
}
return global::System.Text.RegularExpressions.Syntax.Parser.Unescape(str);
}
/// Indicates whether the regular expression finds a match in the input string using the regular expression specified in the parameter.
/// true if the regular expression finds a match; otherwise, false.
/// The string to search for a match.
/// The regular expression pattern to match.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.
///
///
///
///
// Token: 0x06001932 RID: 6450 RVA: 0x00056200 File Offset: 0x00054400
public static bool IsMatch(string input, string pattern)
{
return Regex.IsMatch(input, pattern, RegexOptions.None);
}
/// Indicates whether the regular expression finds a match in the input string, using the regular expression specified in the parameter and the matching options supplied in the parameter.
/// true if the regular expression finds a match; otherwise, false.
/// The string to search for a match.
/// The regular expression pattern to match.
/// A bitwise OR combination of the enumeration values.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.
///
/// is not a valid value.
///
///
///
///
// Token: 0x06001933 RID: 6451 RVA: 0x0005620C File Offset: 0x0005440C
public static bool IsMatch(string input, string pattern, RegexOptions options)
{
Regex regex = new Regex(pattern, options);
return regex.IsMatch(input);
}
/// Searches the specified input string for the first occurrence of the regular expression supplied in the parameter.
/// An object that contains information about the match.
/// The string to search for a match.
/// The regular expression pattern to match.
/// A regular expression parsing error has occurred.
///
/// is null. -or- is null.
///
///
///
///
// Token: 0x06001934 RID: 6452 RVA: 0x00056228 File Offset: 0x00054428
public static Match Match(string input, string pattern)
{
return Regex.Match(input, pattern, RegexOptions.None);
}
/// Searches the input string for the first occurrence of the regular expression supplied in a parameter, using the matching options supplied in the parameter.
/// An object that contains information about the match.
/// The string to be tested for a match.
/// The regular expression pattern to match.
/// A bitwise OR combination of the enumeration values.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.
///
/// is not a valid bitwise combination of values.
///
///
///
///
// Token: 0x06001935 RID: 6453 RVA: 0x00056234 File Offset: 0x00054434
public static Match Match(string input, string pattern, RegexOptions options)
{
Regex regex = new Regex(pattern, options);
return regex.Match(input);
}
/// Searches the specified input string for all occurrences of the regular expression specified in the parameter.
/// A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
/// The string to search for a match.
/// The regular expression pattern to match.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.
///
///
///
///
// Token: 0x06001936 RID: 6454 RVA: 0x00056250 File Offset: 0x00054450
public static MatchCollection Matches(string input, string pattern)
{
return Regex.Matches(input, pattern, RegexOptions.None);
}
/// Searches the specified input string for all occurrences of a specified regular expression, using the specified matching options.
/// A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
/// The string to search for a match.
/// The regular expression pattern to match.
/// A bitwise combination of the enumeration values that specify options for matching.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.
///
/// is not a valid bitwise combination of values.
///
///
///
///
// Token: 0x06001937 RID: 6455 RVA: 0x0005625C File Offset: 0x0005445C
public static MatchCollection Matches(string input, string pattern, RegexOptions options)
{
Regex regex = new Regex(pattern, options);
return regex.Matches(input);
}
/// Within a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// The regular expression pattern to match.
/// A custom method that examines each match and returns either the original matched string or a replacement string.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.-or- is null.
///
///
///
///
// Token: 0x06001938 RID: 6456 RVA: 0x00056278 File Offset: 0x00054478
public static string Replace(string input, string pattern, MatchEvaluator evaluator)
{
return Regex.Replace(input, pattern, evaluator, RegexOptions.None);
}
/// Within a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate. Specified options modify the matching operation.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// The regular expression pattern to match.
/// A custom method that examines each match and returns either the original matched string or a replacement string.
/// A bitwise OR combination of the enumeration values.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.-or- is null.
///
/// is not a valid bitwise combination of values.
///
///
///
///
// Token: 0x06001939 RID: 6457 RVA: 0x00056284 File Offset: 0x00054484
public static string Replace(string input, string pattern, MatchEvaluator evaluator, RegexOptions options)
{
Regex regex = new Regex(pattern, options);
return regex.Replace(input, evaluator);
}
/// Within a specified input string, replaces all strings that match a specified regular expression with a specified replacement string.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// The regular expression pattern to match.
/// The replacement string.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.-or- is null.
///
///
///
///
// Token: 0x0600193A RID: 6458 RVA: 0x000562A4 File Offset: 0x000544A4
public static string Replace(string input, string pattern, string replacement)
{
return Regex.Replace(input, pattern, replacement, RegexOptions.None);
}
/// Within a specified input string, replaces all strings that match a specified regular expression with a specified replacement string. Specified options modify the matching operation.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// The regular expression pattern to match.
/// The replacement string.
/// A bitwise OR combination of the enumeration values.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.-or- is null.
///
/// is not a valid bitwise combination of values.
///
///
///
///
// Token: 0x0600193B RID: 6459 RVA: 0x000562B0 File Offset: 0x000544B0
public static string Replace(string input, string pattern, string replacement, RegexOptions options)
{
Regex regex = new Regex(pattern, options);
return regex.Replace(input, replacement);
}
/// Splits the input string at the positions defined by a regular expression pattern.
/// An array of strings.
/// The string to split.
/// The regular expression pattern to match.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.
///
///
///
///
// Token: 0x0600193C RID: 6460 RVA: 0x000562D0 File Offset: 0x000544D0
public static string[] Split(string input, string pattern)
{
return Regex.Split(input, pattern, RegexOptions.None);
}
/// Splits the input string at the positions defined by a specified regular expression pattern. Specified options modify the matching operation.
/// An array of strings.
/// The string to split.
/// The regular expression pattern to match.
/// A bitwise OR combination of the enumeration values.
/// A regular expression parsing error has occurred.
///
/// is null.-or- is null.
///
/// is not a valid bitwise combination of values.
///
///
///
///
// Token: 0x0600193D RID: 6461 RVA: 0x000562DC File Offset: 0x000544DC
public static string[] Split(string input, string pattern, RegexOptions options)
{
Regex regex = new Regex(pattern, options);
return regex.Split(input);
}
/// Gets or sets the maximum number of entries in the current static cache of compiled regular expressions.
/// The maximum number of entries in the static cache.
/// The value in a set operation is less than zero.
// Token: 0x170007E8 RID: 2024
// (get) Token: 0x0600193E RID: 6462 RVA: 0x000562F8 File Offset: 0x000544F8
// (set) Token: 0x0600193F RID: 6463 RVA: 0x00056304 File Offset: 0x00054504
public static int CacheSize
{
get
{
return Regex.cache.Capacity;
}
set
{
if (value < 0)
{
throw new ArgumentOutOfRangeException("CacheSize");
}
Regex.cache.Capacity = value;
}
}
// Token: 0x06001940 RID: 6464 RVA: 0x00056324 File Offset: 0x00054524
private static void validate_options(RegexOptions options)
{
if ((options & ~(RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | RegexOptions.RightToLeft | RegexOptions.ECMAScript | RegexOptions.CultureInvariant)) != RegexOptions.None)
{
throw new ArgumentOutOfRangeException("options");
}
if ((options & RegexOptions.ECMAScript) != RegexOptions.None && (options & ~(RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.ECMAScript)) != RegexOptions.None)
{
throw new ArgumentOutOfRangeException("options");
}
}
// Token: 0x06001941 RID: 6465 RVA: 0x0005636C File Offset: 0x0005456C
private void Init()
{
this.machineFactory = Regex.cache.Lookup(this.pattern, this.roptions);
if (this.machineFactory == null)
{
this.InitNewRegex();
}
else
{
this.group_count = this.machineFactory.GroupCount;
this.gap = this.machineFactory.Gap;
this.mapping = this.machineFactory.Mapping;
this.group_names = this.machineFactory.NamesMapping;
}
}
// Token: 0x06001942 RID: 6466 RVA: 0x000563F0 File Offset: 0x000545F0
private void InitNewRegex()
{
this.machineFactory = Regex.CreateMachineFactory(this.pattern, this.roptions);
Regex.cache.Add(this.pattern, this.roptions, this.machineFactory);
this.group_count = this.machineFactory.GroupCount;
this.gap = this.machineFactory.Gap;
this.mapping = this.machineFactory.Mapping;
this.group_names = this.machineFactory.NamesMapping;
}
// Token: 0x06001943 RID: 6467 RVA: 0x00056474 File Offset: 0x00054674
private static IMachineFactory CreateMachineFactory(string pattern, RegexOptions options)
{
global::System.Text.RegularExpressions.Syntax.Parser parser = new global::System.Text.RegularExpressions.Syntax.Parser();
global::System.Text.RegularExpressions.Syntax.RegularExpression regularExpression = parser.ParseRegularExpression(pattern, options);
ICompiler compiler = new PatternCompiler();
regularExpression.Compile(compiler, (options & RegexOptions.RightToLeft) != RegexOptions.None);
IMachineFactory machineFactory = compiler.GetMachineFactory();
Hashtable hashtable = new Hashtable();
machineFactory.Gap = parser.GetMapping(hashtable);
machineFactory.Mapping = hashtable;
machineFactory.NamesMapping = Regex.GetGroupNamesArray(machineFactory.GroupCount, machineFactory.Mapping);
return machineFactory;
}
/// Returns the options passed into the constructor.
/// The parameter that was passed into the constructor.
// Token: 0x170007E9 RID: 2025
// (get) Token: 0x06001944 RID: 6468 RVA: 0x000564E4 File Offset: 0x000546E4
public RegexOptions Options
{
get
{
return this.roptions;
}
}
/// Gets a value indicating whether the regular expression searches from right to left.
/// true if the regular expression searches from right to left; otherwise false.
// Token: 0x170007EA RID: 2026
// (get) Token: 0x06001945 RID: 6469 RVA: 0x000564EC File Offset: 0x000546EC
public bool RightToLeft
{
get
{
return (this.roptions & RegexOptions.RightToLeft) != RegexOptions.None;
}
}
/// Returns an array of capturing group names for the regular expression.
/// A string array of group names.
///
///
///
// Token: 0x06001946 RID: 6470 RVA: 0x00056500 File Offset: 0x00054700
public string[] GetGroupNames()
{
string[] array = new string[1 + this.group_count];
Array.Copy(this.group_names, array, 1 + this.group_count);
return array;
}
/// Returns an array of capturing group numbers that correspond to group names in an array.
/// An integer array of group numbers.
// Token: 0x06001947 RID: 6471 RVA: 0x00056530 File Offset: 0x00054730
public int[] GetGroupNumbers()
{
int[] array = new int[1 + this.group_count];
Array.Copy(this.GroupNumbers, array, 1 + this.group_count);
return array;
}
/// Returns the group name that corresponds to the specified group number.
/// A string that contains the group name associated with the specified group number. If there is no group name that corresponds to , the method returns .
/// The group number to convert to the corresponding group name.
// Token: 0x06001948 RID: 6472 RVA: 0x00056560 File Offset: 0x00054760
public string GroupNameFromNumber(int i)
{
i = this.GetGroupIndex(i);
if (i < 0)
{
return string.Empty;
}
return this.group_names[i];
}
/// Returns the group number that corresponds to the specified group name.
/// The group number that corresponds to the specified group name.
/// The group name to convert to the corresponding group number.
///
/// is null.
// Token: 0x06001949 RID: 6473 RVA: 0x00056580 File Offset: 0x00054780
public int GroupNumberFromName(string name)
{
if (!this.mapping.Contains(name))
{
return -1;
}
int num = (int)this.mapping[name];
if (num >= this.gap)
{
num = int.Parse(name);
}
return num;
}
// Token: 0x0600194A RID: 6474 RVA: 0x000565C8 File Offset: 0x000547C8
internal int GetGroupIndex(int number)
{
if (number < this.gap)
{
return number;
}
if (this.gap > this.group_count)
{
return -1;
}
return Array.BinarySearch(this.GroupNumbers, this.gap, this.group_count - this.gap + 1, number);
}
// Token: 0x0600194B RID: 6475 RVA: 0x00056618 File Offset: 0x00054818
private int default_startat(string input)
{
return (!this.RightToLeft || input == null) ? 0 : input.Length;
}
/// Indicates whether the regular expression specified in the constructor finds a match in the input string.
/// true if the regular expression finds a match; otherwise, false.
/// The string to search for a match.
///
/// is null.
///
///
///
///
// Token: 0x0600194C RID: 6476 RVA: 0x00056638 File Offset: 0x00054838
public bool IsMatch(string input)
{
return this.IsMatch(input, this.default_startat(input));
}
/// Indicates whether the regular expression specified in the constructor finds a match in the input string beginning at the specified starting position in the string.
/// true if the regular expression finds a match; otherwise, false.
/// The string to search for a match.
/// The character position at which to start the search.
///
/// is null.
///
/// cannot be less than zero or greater than the length of .
///
///
///
///
// Token: 0x0600194D RID: 6477 RVA: 0x00056648 File Offset: 0x00054848
public bool IsMatch(string input, int startat)
{
return this.Match(input, startat).Success;
}
/// Searches the specified input string for the first occurrence of the regular expression specified in the constructor.
/// An object that contains information about the match.
/// The string to search for a match.
///
/// is null.
///
///
///
///
// Token: 0x0600194E RID: 6478 RVA: 0x00056658 File Offset: 0x00054858
public Match Match(string input)
{
return this.Match(input, this.default_startat(input));
}
/// Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position in the string.
/// An object that contains information about the match.
/// The string to search for a match.
/// The zero-based character position at which to start the search.
///
/// is null.
///
/// is less than zero or greater than the length of .
///
///
///
///
// Token: 0x0600194F RID: 6479 RVA: 0x00056668 File Offset: 0x00054868
public Match Match(string input, int startat)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
if (startat < 0 || startat > input.Length)
{
throw new ArgumentOutOfRangeException("startat");
}
return this.CreateMachine().Scan(this, input, startat, input.Length);
}
/// Searches the input string for the first occurrence of a regular expression, beginning at the specified starting position and searching only the specified number of characters.
/// An object that contains information about the match.
/// The string to be tested for a match.
/// The zero-based character position in the input string at which to begin the search.
/// The number of characters in the substring to include in the search.
///
/// is null.
///
/// is less than zero or greater than the length of .-or- is less than zero or greater than the length of .
///
///
///
///
// Token: 0x06001950 RID: 6480 RVA: 0x000566B8 File Offset: 0x000548B8
public Match Match(string input, int startat, int length)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
if (startat < 0 || startat > input.Length)
{
throw new ArgumentOutOfRangeException("startat");
}
if (length < 0 || length > input.Length - startat)
{
throw new ArgumentOutOfRangeException("length");
}
return this.CreateMachine().Scan(this, input, startat, startat + length);
}
/// Searches the specified input string for all occurrences of a regular expression.
/// A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
/// The string to search for a match.
///
/// is null.
///
///
///
///
// Token: 0x06001951 RID: 6481 RVA: 0x00056728 File Offset: 0x00054928
public MatchCollection Matches(string input)
{
return this.Matches(input, this.default_startat(input));
}
/// Searches the specified input string for all occurrences of a regular expression, beginning at the specified starting position in the string.
/// A collection of the objects found by the search. If no matches are found, the method returns an empty collection object.
/// The string to search for a match.
/// The character position in the input string at which to start the search.
///
/// is null.
///
/// is less than zero or greater than the length of .
///
///
///
///
// Token: 0x06001952 RID: 6482 RVA: 0x00056738 File Offset: 0x00054938
public MatchCollection Matches(string input, int startat)
{
Match match = this.Match(input, startat);
return new MatchCollection(match);
}
/// Within a specified input string, replaces all strings that match a specified regular expression with a string returned by a delegate.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// A custom method that examines each match and returns either the original matched string or a replacement string.
///
/// is null.-or- is null.
///
///
///
///
// Token: 0x06001953 RID: 6483 RVA: 0x00056754 File Offset: 0x00054954
public string Replace(string input, MatchEvaluator evaluator)
{
return this.Replace(input, evaluator, int.MaxValue, this.default_startat(input));
}
/// Within a specified input string, replaces a specified maximum number of strings that match a regular expression pattern with a string returned by a delegate.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// A custom method that examines each match and returns either the original matched string or a replacement string.
/// The maximum number of times the replacement will occur.
///
/// is null.-or- is null.
///
///
///
///
// Token: 0x06001954 RID: 6484 RVA: 0x0005676C File Offset: 0x0005496C
public string Replace(string input, MatchEvaluator evaluator, int count)
{
return this.Replace(input, evaluator, count, this.default_startat(input));
}
/// Within a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a string returned by a delegate.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// A custom method that examines each match and returns either the original matched string or a replacement string.
/// The maximum number of times the replacement will occur.
/// The character position in the input string where the search begins.
///
/// is null.-or- is null.
///
/// is less than zero or greater than the length of .
///
///
///
///
// Token: 0x06001955 RID: 6485 RVA: 0x00056780 File Offset: 0x00054980
public string Replace(string input, MatchEvaluator evaluator, int count, int startat)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
if (evaluator == null)
{
throw new ArgumentNullException("evaluator");
}
if (count < -1)
{
throw new ArgumentOutOfRangeException("count");
}
if (startat < 0 || startat > input.Length)
{
throw new ArgumentOutOfRangeException("startat");
}
BaseMachine baseMachine = (BaseMachine)this.CreateMachine();
if (this.RightToLeft)
{
return baseMachine.RTLReplace(this, input, evaluator, count, startat);
}
Regex.Adapter adapter = new Regex.Adapter(evaluator);
return baseMachine.LTRReplace(this, input, new BaseMachine.MatchAppendEvaluator(adapter.Evaluate), count, startat);
}
/// Within a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// The replacement string.
///
/// is null.-or- is null.
///
///
///
///
// Token: 0x06001956 RID: 6486 RVA: 0x00056824 File Offset: 0x00054A24
public string Replace(string input, string replacement)
{
return this.Replace(input, replacement, int.MaxValue, this.default_startat(input));
}
/// Within a specified input string, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// The replacement string.
/// The maximum number of times the replacement can occur.
///
/// is null.-or- is null.
///
///
///
///
// Token: 0x06001957 RID: 6487 RVA: 0x0005683C File Offset: 0x00054A3C
public string Replace(string input, string replacement, int count)
{
return this.Replace(input, replacement, count, this.default_startat(input));
}
/// Within a specified input substring, replaces a specified maximum number of strings that match a regular expression pattern with a specified replacement string.
/// A new string that is identical to the input string, except that a replacement string takes the place of each matched string.
/// The string to search for a match.
/// The replacement string.
/// Maximum number of times the replacement can occur.
/// The character position in the input string where the search begins.
///
/// is null.-or- is null.
///
/// is less than zero or greater than the length of .
///
///
///
///
// Token: 0x06001958 RID: 6488 RVA: 0x00056850 File Offset: 0x00054A50
public string Replace(string input, string replacement, int count, int startat)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
if (replacement == null)
{
throw new ArgumentNullException("replacement");
}
if (count < -1)
{
throw new ArgumentOutOfRangeException("count");
}
if (startat < 0 || startat > input.Length)
{
throw new ArgumentOutOfRangeException("startat");
}
return this.CreateMachine().Replace(this, input, replacement, count, startat);
}
/// Splits the specified input string at the positions defined by a regular expression pattern specified in the constructor.
/// An array of strings.
/// The string to split.
///
/// is null.
///
///
///
///
// Token: 0x06001959 RID: 6489 RVA: 0x000568C4 File Offset: 0x00054AC4
public string[] Split(string input)
{
return this.Split(input, int.MaxValue, this.default_startat(input));
}
/// Splits the specified input string a specified maximum number of times at the positions defined by a regular expression specified in the constructor.
/// An array of strings.
/// The string to be split.
/// The maximum number of times the split can occur.
///
/// is null.
///
///
///
///
// Token: 0x0600195A RID: 6490 RVA: 0x000568DC File Offset: 0x00054ADC
public string[] Split(string input, int count)
{
return this.Split(input, count, this.default_startat(input));
}
/// Splits the specified input string a specified maximum number of times at the positions defined by a regular expression specified in the constructor. The search for the regular expression pattern starts at a specified character position in the input string.
/// An array of strings.
/// The string to be split.
/// The maximum number of times the split can occur.
/// The character position in the input string where the search will begin.
///
/// is null.
///
/// is less than zero or greater than the length of .
///
///
///
///
// Token: 0x0600195B RID: 6491 RVA: 0x000568F0 File Offset: 0x00054AF0
public string[] Split(string input, int count, int startat)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
if (count < 0)
{
throw new ArgumentOutOfRangeException("count");
}
if (startat < 0 || startat > input.Length)
{
throw new ArgumentOutOfRangeException("startat");
}
return this.CreateMachine().Split(this, input, count, startat);
}
/// Used by a object generated by the method.
/// References have already been initialized.
// Token: 0x0600195C RID: 6492 RVA: 0x00056950 File Offset: 0x00054B50
protected void InitializeReferences()
{
if (this.refsInitialized)
{
throw new NotSupportedException("This operation is only allowed once per object.");
}
this.refsInitialized = true;
this.Init();
}
/// Used by a object generated by the method.
/// true if the property contains the option; otherwise, false.
// Token: 0x0600195D RID: 6493 RVA: 0x00056978 File Offset: 0x00054B78
protected bool UseOptionR()
{
return (this.roptions & RegexOptions.RightToLeft) != RegexOptions.None;
}
/// Returns the regular expression pattern that was passed into the Regex constructor.
/// The parameter that was passed into the Regex constructor.
// Token: 0x0600195E RID: 6494 RVA: 0x0005698C File Offset: 0x00054B8C
public override string ToString()
{
return this.pattern;
}
// Token: 0x170007EB RID: 2027
// (get) Token: 0x0600195F RID: 6495 RVA: 0x00056994 File Offset: 0x00054B94
internal int GroupCount
{
get
{
return this.group_count;
}
}
// Token: 0x170007EC RID: 2028
// (get) Token: 0x06001960 RID: 6496 RVA: 0x0005699C File Offset: 0x00054B9C
internal int Gap
{
get
{
return this.gap;
}
}
// Token: 0x06001961 RID: 6497 RVA: 0x000569A4 File Offset: 0x00054BA4
private IMachine CreateMachine()
{
return this.machineFactory.NewInstance();
}
// Token: 0x06001962 RID: 6498 RVA: 0x000569B4 File Offset: 0x00054BB4
private static string[] GetGroupNamesArray(int groupCount, IDictionary mapping)
{
string[] array = new string[groupCount + 1];
IDictionaryEnumerator enumerator = mapping.GetEnumerator();
while (enumerator.MoveNext())
{
array[(int)enumerator.Value] = (string)enumerator.Key;
}
return array;
}
// Token: 0x170007ED RID: 2029
// (get) Token: 0x06001963 RID: 6499 RVA: 0x000569FC File Offset: 0x00054BFC
private int[] GroupNumbers
{
get
{
if (this.group_numbers == null)
{
this.group_numbers = new int[1 + this.group_count];
for (int i = 0; i < this.gap; i++)
{
this.group_numbers[i] = i;
}
for (int j = this.gap; j <= this.group_count; j++)
{
this.group_numbers[j] = int.Parse(this.group_names[j]);
}
return this.group_numbers;
}
return this.group_numbers;
}
}
// Token: 0x040013D4 RID: 5076
private static FactoryCache cache = new FactoryCache(15);
// Token: 0x040013D5 RID: 5077
private IMachineFactory machineFactory;
// Token: 0x040013D6 RID: 5078
private IDictionary mapping;
// Token: 0x040013D7 RID: 5079
private int group_count;
// Token: 0x040013D8 RID: 5080
private int gap;
// Token: 0x040013D9 RID: 5081
private bool refsInitialized;
// Token: 0x040013DA RID: 5082
private string[] group_names;
// Token: 0x040013DB RID: 5083
private int[] group_numbers;
/// Used by a object generated by the method.
// Token: 0x040013DC RID: 5084
protected internal string pattern;
/// Used by a object generated by the method.
// Token: 0x040013DD RID: 5085
protected internal RegexOptions roptions;
/// Used by a object generated by the method.
// Token: 0x040013DE RID: 5086
[global::System.MonoTODO]
internal Dictionary capnames;
/// Used by a object generated by the method.
// Token: 0x040013DF RID: 5087
[global::System.MonoTODO]
internal Dictionary caps;
/// Used by a object generated by the method.
// Token: 0x040013E0 RID: 5088
[global::System.MonoTODO]
protected internal int capsize;
/// Used by a object generated by the method.
// Token: 0x040013E1 RID: 5089
[global::System.MonoTODO]
protected internal string[] capslist;
// Token: 0x020002B3 RID: 691
private class Adapter
{
// Token: 0x06001964 RID: 6500 RVA: 0x00056A88 File Offset: 0x00054C88
public Adapter(MatchEvaluator ev)
{
this.ev = ev;
}
// Token: 0x06001965 RID: 6501 RVA: 0x00056A98 File Offset: 0x00054C98
public void Evaluate(Match m, StringBuilder sb)
{
sb.Append(this.ev(m));
}
// Token: 0x040013E2 RID: 5090
private MatchEvaluator ev;
}
}
}