src/NuGetGallery.Core/Extensions/RegexEx.cs
/// <summary>
/// In a specific input string, replaces all substrings that match a specified regular expression.
/// </summary>
/// <param name="input">The string to search for matches.</param>
/// <param name="pattern">The regular expression pattern to match.</param>
/// <param name="evaluator">The handler to replace matches.</param>
/// <param name="options">A bitwise combination that provide options for matching.</param>
/// <returns>A new string with the matches replaced, or the original string if the matches timeout.</returns>
In a specific input string, replaces all substrings that match a specified regular expression.
In a specific input string replaces all substrings that match a specified regular expression .
public static string ReplaceWithTimeoutOrOriginal(
            string input,
            string pattern,
            MatchEvaluator evaluator,
            RegexOptions options)
        {
            try
            {
                return Regex.Replace(input, pattern, evaluator, options, Timeout);
            }
            catch (RegexMatchTimeoutException)
            {
                return input;
            }
        }
public static string ReplaceWithTimeoutOrOriginal ( string input , string pattern , MatchEvaluator evaluator , RegexOptions options ) { try { return Regex . Replace ( input , pattern , evaluator , options , Timeout ) ; } catch ( RegexMatchTimeoutException ) { return input ; } }
In a specific input string, replaces all substrings that match a specified regular expression.
In a specific input string replaces all substrings that match a specified regular expression .
A new string with the matches replaced, or the original string if the matches timeout.
A new string with the matches replaced or the original string if the matches timeout .
input
string
The string to search for matches.
The string to search for matches .
pattern
string
The regular expression pattern to match.
The regular expression pattern to match .
evaluator
MatchEvaluator
The handler to replace matches.
The handler to replace matches .
options
RegexOptions
A bitwise combination that provide options for matching.
A bitwise combination that provide options for matching .