15 [global::__DynamicallyInvokable]
32 [global::__DynamicallyInvokable]
36 [OptionalField(VersionAdded = 2)]
39 private const string DefaultMatchTimeout_ConfigKeyName =
"REGEX_DEFAULT_MATCH_TIMEOUT";
45 internal static readonly
TimeSpan DefaultMatchTimeout = InitDefaultMatchTimeout();
59 internal ExclusiveReference runnerref;
61 internal SharedReference replref;
63 internal RegexCode code;
65 internal bool refsInitialized;
69 internal static int cacheSize = 15;
71 internal const int MaxOptionShift = 10;
100 [CLSCompliant(
false)]
124 [global::__DynamicallyInvokable]
127 [global::__DynamicallyInvokable]
132 [global::__DynamicallyInvokable]
140 if (livecode.
Count > cacheSize)
144 while (livecode.
Count > cacheSize)
155 [global::__DynamicallyInvokable]
158 [global::__DynamicallyInvokable]
167 [global::__DynamicallyInvokable]
170 [global::__DynamicallyInvokable]
180 [global::__DynamicallyInvokable]
183 [global::__DynamicallyInvokable]
191 [global::__DynamicallyInvokable]
202 [global::__DynamicallyInvokable]
216 [global::__DynamicallyInvokable]
218 : this(
pattern, options, DefaultMatchTimeout, useCache: false)
232 [global::__DynamicallyInvokable]
234 : this(
pattern, options, matchTimeout, useCache: false)
240 CachedCodeEntry cachedCodeEntry =
null;
246 if (options <
RegexOptions.None || (
int)options >> 10 != 0)
256 string[] obj =
new string[5];
257 int num = (int)options;
263 string key =
string.Concat(obj);
264 cachedCodeEntry = LookupCachedAndUpdate(key);
268 if (cachedCodeEntry ==
null)
273 code = RegexWriter.Write(regexTree);
280 cachedCodeEntry = CacheCode(key);
285 caps = cachedCodeEntry._caps;
286 capnames = cachedCodeEntry._capnames;
287 capslist = cachedCodeEntry._capslist;
288 capsize = cachedCodeEntry._capsize;
289 code = cachedCodeEntry._code;
290 factory = cachedCodeEntry._factory;
291 runnerref = cachedCodeEntry._runnerref;
292 replref = cachedCodeEntry._replref;
293 refsInitialized =
true;
300 cachedCodeEntry?.AddCompiled(
factory);
314 : this(info.GetString(
"pattern"), (
RegexOptions)info.GetInt32(
"options"))
318 long @
int = info.GetInt64(
"matchTimeout");
349 private static TimeSpan InitDefaultMatchTimeout()
352 object data = currentDomain.
GetData(
"REGEX_DEFAULT_MATCH_TIMEOUT");
355 return FallbackDefaultMatchTimeout;
359 throw new InvalidCastException(SR.GetString(
"IllegalDefaultRegexMatchTimeoutInAppDomain",
"REGEX_DEFAULT_MATCH_TIMEOUT"));
367 catch (ArgumentOutOfRangeException)
369 throw new ArgumentOutOfRangeException(SR.GetString(
"IllegalDefaultRegexMatchTimeoutInAppDomain",
"REGEX_DEFAULT_MATCH_TIMEOUT"));
374 [HostProtection(
SecurityAction.LinkDemand, MayLeakOnAbort =
true)]
377 return RegexCompiler.Compile(code,
roptions);
385 [global::__DynamicallyInvokable]
392 return RegexParser.Escape(str);
402 [global::__DynamicallyInvokable]
409 return RegexParser.Unescape(str);
414 [global::__DynamicallyInvokable]
422 [global::__DynamicallyInvokable]
429 array =
new string[num];
430 for (
int i = 0; i < num; i++)
437 array =
new string[
capslist.Length];
445 [global::__DynamicallyInvokable]
452 array =
new int[num];
453 for (
int i = 0; i < num; i++)
464 array[(int)enumerator.
Value] = (
int)enumerator.
Key;
473 [global::__DynamicallyInvokable]
486 object obj =
caps[i];
505 [global::__DynamicallyInvokable]
523 foreach (
char c
in name)
525 if (c >
'9' || c <
'0')
548 [global::__DynamicallyInvokable]
566 [global::__DynamicallyInvokable]
586 [global::__DynamicallyInvokable]
589 return new Regex(
pattern, options, matchTimeout, useCache:
true).IsMatch(input);
599 [global::__DynamicallyInvokable]
619 [global::__DynamicallyInvokable]
620 public bool IsMatch(
string input,
int startat)
626 return Run(quick:
true, -1, input, 0, input.Length, startat) ==
null;
637 [global::__DynamicallyInvokable]
654 [global::__DynamicallyInvokable]
657 return Match(input,
pattern, options, DefaultMatchTimeout);
673 [global::__DynamicallyInvokable]
676 return new Regex(
pattern, options, matchTimeout, useCache:
true).Match(input);
685 [global::__DynamicallyInvokable]
704 [global::__DynamicallyInvokable]
711 return Run(quick:
false, -1, input, 0, input.Length, startat);
726 [global::__DynamicallyInvokable]
733 return Run(quick:
false, -1, input, beginning, length,
UseOptionR() ? (beginning + length) : beginning);
743 [global::__DynamicallyInvokable]
759 [global::__DynamicallyInvokable]
777 [global::__DynamicallyInvokable]
780 return new Regex(
pattern, options, matchTimeout, useCache:
true).Matches(input);
788 [global::__DynamicallyInvokable]
806 [global::__DynamicallyInvokable]
825 [global::__DynamicallyInvokable]
843 [global::__DynamicallyInvokable]
846 return Replace(input,
pattern, replacement, options, DefaultMatchTimeout);
863 [global::__DynamicallyInvokable]
866 return new Regex(
pattern, options, matchTimeout, useCache:
true).Replace(input, replacement);
876 [global::__DynamicallyInvokable]
877 public string Replace(
string input,
string replacement)
894 [global::__DynamicallyInvokable]
895 public string Replace(
string input,
string replacement,
int count)
915 [global::__DynamicallyInvokable]
916 public string Replace(
string input,
string replacement,
int count,
int startat)
922 if (replacement ==
null)
926 RegexReplacement regexReplacement = (RegexReplacement)replref.Get();
927 if (regexReplacement ==
null || !regexReplacement.Pattern.Equals(replacement))
930 replref.Cache(regexReplacement);
932 return regexReplacement.Replace(
this, input, count, startat);
944 [global::__DynamicallyInvokable]
962 [global::__DynamicallyInvokable]
965 return Replace(input,
pattern, evaluator, options, DefaultMatchTimeout);
982 [global::__DynamicallyInvokable]
985 return new Regex(
pattern, options, matchTimeout, useCache:
true).Replace(input, evaluator);
995 [global::__DynamicallyInvokable]
1013 [global::__DynamicallyInvokable]
1034 [global::__DynamicallyInvokable]
1041 return RegexReplacement.Replace(evaluator,
this, input, count, startat);
1052 [global::__DynamicallyInvokable]
1069 [global::__DynamicallyInvokable]
1072 return Split(input,
pattern, options, DefaultMatchTimeout);
1088 [global::__DynamicallyInvokable]
1091 return new Regex(
pattern, options, matchTimeout, useCache:
true).Split(input);
1100 [global::__DynamicallyInvokable]
1117 [global::__DynamicallyInvokable]
1118 public string[]
Split(
string input,
int count)
1124 return RegexReplacement.Split(
this, input, count,
UseOptionR() ? input.Length : 0);
1137 [global::__DynamicallyInvokable]
1138 public string[]
Split(
string input,
int count,
int startat)
1144 return RegexReplacement.Split(
this, input, count, startat);
1153 [HostProtection(
SecurityAction.LinkDemand, MayLeakOnAbort =
true)]
1156 CompileToAssemblyInternal(regexinfos, assemblyname,
null,
null);
1166 [HostProtection(
SecurityAction.LinkDemand, MayLeakOnAbort =
true)]
1169 CompileToAssemblyInternal(regexinfos, assemblyname, attributes,
null);
1182 [HostProtection(
SecurityAction.LinkDemand, MayLeakOnAbort =
true)]
1185 CompileToAssemblyInternal(regexinfos, assemblyname, attributes, resourceFile);
1190 if (assemblyname ==
null)
1194 if (regexinfos ==
null)
1198 RegexCompiler.CompileToAssembly(regexinfos, assemblyname, attributes, resourceFile);
1205 if (refsInitialized)
1209 refsInitialized =
true;
1210 runnerref =
new ExclusiveReference();
1211 replref =
new SharedReference();
1214 internal Match Run(
bool quick,
int prevlen,
string input,
int beginning,
int length,
int startat)
1217 if (startat < 0 || startat > input.Length)
1221 if (length < 0 || length > input.Length)
1225 regexRunner = (RegexRunner)runnerref.Get();
1226 if (regexRunner ==
null)
1232 return regexRunner.
Scan(
this, input, beginning, beginning + length, startat, prevlen, quick,
internalMatchTimeout);
1236 runnerref.Release(regexRunner);
1240 private static CachedCodeEntry LookupCachedAndUpdate(
string key)
1246 if (linkedListNode.Value._key == key)
1248 livecode.
Remove(linkedListNode);
1250 return linkedListNode.Value;
1257 private CachedCodeEntry CacheCode(
string key)
1259 CachedCodeEntry result =
null;
1264 if (linkedListNode.Value._key == key)
1266 livecode.
Remove(linkedListNode);
1268 return linkedListNode.Value;
1277 if (livecode.
Count <= cacheSize)
1302 internal bool UseOptionInvariant()
Converts a base data type to another base data type.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
IDictionary CapNames
Gets or sets a dictionary that maps named capturing groups to their index values.
string [] Split(string input)
Splits an input string into an array of substrings at the positions defined by a regular expression p...
RegexOptions Options
Gets the options that were passed into the T:System.Text.RegularExpressions.Regex constructor.
static string Replace(string input, string pattern, string replacement, RegexOptions options)
In a specified input string, replaces all strings that match a specified regular expression with a sp...
static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes)
Compiles one or more specified T:System.Text.RegularExpressions.Regex objects to a named assembly wit...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Regex()
Initializes a new instance of the T:System.Text.RegularExpressions.Regex class.
Creates a T:System.Text.RegularExpressions.RegexRunner class for a compiled regular expression.
bool MoveNext()
Advances the enumerator to the next element of the collection.
bool IsMatch(string input, int startat)
Indicates whether the regular expression specified in the T:System.Text.RegularExpressions....
MatchCollection Matches(string input)
Searches the specified input string for all occurrences of a regular expression.
bool Remove(T value)
Removes the first occurrence of the specified value from the T:System.Collections....
static string [] Split(string input, string pattern)
Splits an input string into an array of substrings at the positions defined by a regular expression p...
static Match Match(string input, string pattern)
Searches the specified input string for the first occurrence of the specified regular expression.
override string ToString()
Returns the regular expression pattern that was passed into the Regex constructor.
internal TimeSpan internalMatchTimeout
The maximum amount of time that can elapse in a pattern-matching operation before the operation times...
string [] GetGroupNames()
Returns an array of capturing group names for the regular expression.
string [] Split(string input, int count, int startat)
Splits an input string a specified maximum number of times into an array of substrings,...
LinkedListNode< T > AddFirst(T value)
Adds a new node containing the specified value at the start of the T:System.Collections....
object Key
Gets the key of the current dictionary entry.
static string Unescape(string str)
Converts any escaped characters in the input string.
IDictionary Caps
Gets or sets a dictionary that maps numbered capturing groups to their index values.
LinkedListNode< T > First
Gets the first node of the T:System.Collections.Generic.LinkedList`1.
internal Match Scan(Regex regex, string text, int textbeg, int textend, int textstart, int prevlen, bool quick)
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
bool IsMatch(string input)
Indicates whether the regular expression specified in the T:System.Text.RegularExpressions....
The exception that is thrown when the value of an argument is outside the allowable range of values a...
The exception that is thrown for invalid casting or explicit conversion.
static bool IsMatch(string input, string pattern)
Indicates whether the specified regular expression finds a match in the specified input string.
MatchCollection Matches(string input, int startat)
Searches the specified input string for all occurrences of a regular expression, beginning at the spe...
static string Replace(string input, string pattern, string replacement)
In a specified input string, replaces all strings that match a specified regular expression with a sp...
static internal void ValidateMatchTimeout(TimeSpan matchTimeout)
Checks whether a time-out interval is within an acceptable range.
string Replace(string input, MatchEvaluator evaluator, int count, int startat)
In a specified input substring, replaces a specified maximum number of strings that match a regular e...
internal Hashtable capnames
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
static TimeSpan FromMilliseconds(double value)
Returns a T:System.TimeSpan that represents a specified number of milliseconds.
static Match Match(string input, string pattern, RegexOptions options, TimeSpan matchTimeout)
Searches the input string for the first occurrence of the specified regular expression,...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
internal int capsize
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
static AppDomain CurrentDomain
Gets the current application domain for the current T:System.Threading.Thread.
Helps build custom attributes.
Provides information about a regular expression that is used to compile a regular expression to a sta...
Represents an application domain, which is an isolated environment where applications execute....
static int CacheSize
Gets or sets the maximum number of entries in the current static cache of compiled regular expression...
override string ToString()
Returns a string containing the name of the current T:System.Globalization.CultureInfo in the format ...
static Match Match(string input, string pattern, RegexOptions options)
Searches the input string for the first occurrence of the specified regular expression,...
int Count
Gets the number of nodes actually contained in the T:System.Collections.Generic.LinkedList`1.
static readonly TimeSpan InfiniteTimeSpan
A constant used to specify an infinite waiting period, for methods that accept a T:System....
static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname)
Compiles one or more specified T:System.Text.RegularExpressions.Regex objects to a named assembly.
Match Match(string input, int beginning, int length)
Searches the input string for the first occurrence of a regular expression, beginning at the specifie...
long Ticks
Gets the number of ticks that represent the value of the current T:System.TimeSpan structure.
Regex(SerializationInfo info, StreamingContext context)
Initializes a new instance of the T:System.Text.RegularExpressions.Regex class by using serialized da...
Represents a node in a T:System.Collections.Generic.LinkedList`1. This class cannot be inherited.
SecurityAction
Specifies the security actions that can be performed using declarative security.
internal RegexRunnerFactory factory
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
Regex(string pattern)
Initializes a new instance of the T:System.Text.RegularExpressions.Regex class for the specified regu...
Match Match(string input)
Searches the specified input string for the first occurrence of the regular expression specified in t...
string Replace(string input, string replacement)
In a specified input string, replaces all strings that match a regular expression pattern with a spec...
void AddValue(string name, object value, Type type)
Adds a value into the T:System.Runtime.Serialization.SerializationInfo store, where value is associa...
static string [] Split(string input, string pattern, RegexOptions options, TimeSpan matchTimeout)
Splits an input string into an array of substrings at the positions defined by a specified regular ex...
int [] GetGroupNumbers()
Returns an array of capturing group numbers that correspond to group names in an array.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
bool UseOptionR()
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
internal Hashtable caps
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
void InitializeReferences()
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
static string Replace(string input, string pattern, MatchEvaluator evaluator, RegexOptions options, TimeSpan matchTimeout)
In a specified input string, replaces all substrings that match a specified regular expression with a...
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
string Replace(string input, string replacement, int count)
In a specified input string, replaces a specified maximum number of strings that match a regular expr...
static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes, string resourceFile)
Compiles one or more specified T:System.Text.RegularExpressions.Regex objects and a specified resourc...
string Replace(string input, string replacement, int count, int startat)
In a specified input substring, replaces a specified maximum number of strings that match a regular e...
The exception thrown when an error occurs during serialization or deserialization.
static bool IsMatch(string input, string pattern, RegexOptions options, TimeSpan matchTimeout)
Indicates whether the specified regular expression finds a match in the specified input string,...
static readonly TimeSpan Zero
Represents the zero T:System.TimeSpan value. This field is read-only.
MethodImplOptions
Defines the details of how a method is implemented.
bool UseOptionC()
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
Contains constants that specify infinite time-out intervals. This class cannot be inherited.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
RegexOptions
Provides enumerated values to use to set regular expression options.
int GroupNumberFromName(string name)
Returns the group number that corresponds to the specified group name.
string [] Split(string input, int count)
Splits an input string a specified maximum number of times into an array of substrings,...
Represents the results from a single regular expression match.
bool RightToLeft
Gets a value that indicates whether the regular expression searches from right to left.
string Replace(string input, MatchEvaluator evaluator, int count)
In a specified input string, replaces a specified maximum number of strings that match a regular expr...
Describes an assembly's unique identity in full.
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
static string [] Split(string input, string pattern, RegexOptions options)
Splits an input string into an array of substrings at the positions defined by a specified regular ex...
static string Escape(string str)
Escapes a minimal set of characters (\, *, +, ?, |, {, [, (,), ^, $,., #, and white space) by replaci...
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
string GroupNameFromNumber(int i)
Gets the group name that corresponds to the specified group number.
Allows an object to control its own serialization and deserialization.
static TimeSpan Parse(string s)
Converts the string representation of a time interval to its T:System.TimeSpan equivalent.
static MatchCollection Matches(string input, string pattern, RegexOptions options)
Searches the specified input string for all occurrences of a specified regular expression,...
internal string [] capslist
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
Regex(string pattern, RegexOptions options)
Initializes a new instance of the T:System.Text.RegularExpressions.Regex class for the specified regu...
Match Match(string input, int startat)
Searches the input string for the first occurrence of a regular expression, beginning at the specifie...
object Value
Gets the value of the current dictionary entry.
Represents a time interval.To browse the .NET Framework source code for this type,...
Regex(string pattern, RegexOptions options, TimeSpan matchTimeout)
Initializes a new instance of the T:System.Text.RegularExpressions.Regex class for the specified regu...
static string Replace(string input, string pattern, string replacement, RegexOptions options, TimeSpan matchTimeout)
In a specified input string, replaces all strings that match a specified regular expression with a sp...
abstract internal RegexRunner CreateInstance()
When overridden in a derived class, creates a T:System.Text.RegularExpressions.RegexRunner object for...
Specifies that the class can be serialized.
delegate string MatchEvaluator(Match match)
Represents the method that is called each time a regular expression match is found during a Overload:...
static string ToString(object value)
Converts the value of the specified object to its equivalent string representation.
Enumerates the elements of a nongeneric dictionary.
TimeSpan MatchTimeout
Gets the time-out interval of the current instance.
internal RegexOptions roptions
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
string Replace(string input, MatchEvaluator evaluator)
In a specified input string, replaces all strings that match a specified regular expression with a st...
static MatchCollection Matches(string input, string pattern)
Searches the specified input string for all occurrences of a specified regular expression.
object GetData(string name)
Gets the value stored in the current application domain for the specified name.
static MatchCollection Matches(string input, string pattern, RegexOptions options, TimeSpan matchTimeout)
Searches the specified input string for all occurrences of a specified regular expression,...
static string Replace(string input, string pattern, MatchEvaluator evaluator)
In a specified input string, replaces all strings that match a specified regular expression with a st...
Provides information about a specific culture (called a locale for unmanaged code development)....
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
The T:System.Text.RegularExpressions.RegexRunner class is the base class for compiled regular express...
Represents a nongeneric collection of key/value pairs.
static bool IsMatch(string input, string pattern, RegexOptions options)
Indicates whether the specified regular expression finds a match in the specified input string,...
void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
Represents an immutable regular expression.To browse the .NET Framework source code for this type,...
void RemoveLast()
Removes the node at the end of the T:System.Collections.Generic.LinkedList`1.
internal string pattern
Used by a T:System.Text.RegularExpressions.Regex object generated by the Overload:System....
virtual int Count
Gets the number of key/value pairs contained in the T:System.Collections.Hashtable.
Specifies that no options are set. For more information about the default behavior of the regular exp...
static string Replace(string input, string pattern, MatchEvaluator evaluator, RegexOptions options)
In a specified input string, replaces all strings that match a specified regular expression with a st...
static readonly TimeSpan InfiniteMatchTimeout
Specifies that a pattern-matching operation should not time out.
Represents the set of successful matches found by iteratively applying a regular expression pattern t...