RegexExtensions Class
Provides extension methods for Regex.
public static class RegexExtensionsMethods
| Name | Description |
|---|---|
| ReplaceAsync(Regex, string, Func<Match, CancellationToken, ValueTask<string>>, int, int, CancellationToken) | Replaces at most count matches, searched from startat, in the input string using an asynchronous replacement function. |
| ReplaceAsync(Regex, string, Func<Match, CancellationToken, ValueTask<string>>, int, CancellationToken) | Replaces at most count matches in the input string using an asynchronous replacement function. |
| ReplaceAsync(Regex, string, Func<Match, CancellationToken, ValueTask<string>>, CancellationToken) | Replaces all matches in the input string using an asynchronous replacement function. |
| ReplaceAsync(Regex, string, Func<Match, Task<string>>) | Replaces all matches in the input string using an asynchronous replacement function. |
| ReplaceAsync(Regex, string, Func<Match, Task<string>>, int, int, CancellationToken) | Replaces at most count matches, searched from startat, in the input string using an asynchronous replacement function. |
| ReplaceAsync(Regex, string, Func<Match, Task<string>>, int, CancellationToken) | Replaces at most count matches in the input string using an asynchronous replacement function. |
| ReplaceAsync(Regex, string, Func<Match, Task<string>>, CancellationToken) | Replaces all matches in the input string using an asynchronous replacement function. |
ReplaceAsync overloads
ReplaceAsync(Regex, string, Func<Match, CancellationToken, ValueTask<string>>, int, int, CancellationToken)
RegexExtensions.csReplaces at most count matches, searched from startat, in the input string using an asynchronous replacement function.
public static ValueTask<string> ReplaceAsync(this Regex regex, string input, Func<Match, CancellationToken, ValueTask<string>> replacementFn, int count, int startat, CancellationToken cancellationToken = default)Parameters
regexRegex- The regular expression.
inputstring- The string to search for a match.
replacementFnFunc<Match, CancellationToken, ValueTask<string>>- The function that computes the replacement of each match. It receives
cancellationToken. countint- The maximum number of times the replacement can occur, or -1 to replace all the matches.
startatint- The character position in the input string where the search begins, as for
Regex.Replace. cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Remarks
The replacement function is called for each match, in the order the matches are found: from right to left when the regex uses RegexOptions.RightToLeft.
ReplaceAsync(Regex, string, Func<Match, CancellationToken, ValueTask<string>>, int, CancellationToken)
RegexExtensions.csReplaces at most count matches in the input string using an asynchronous replacement function.
public static ValueTask<string> ReplaceAsync(this Regex regex, string input, Func<Match, CancellationToken, ValueTask<string>> replacementFn, int count, CancellationToken cancellationToken = default)Parameters
regexRegex- The regular expression.
inputstring- The string to search for a match.
replacementFnFunc<Match, CancellationToken, ValueTask<string>>- The function that computes the replacement of each match. It receives
cancellationToken. countint- The maximum number of times the replacement can occur, or -1 to replace all the matches.
cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Remarks
The replacement function is called for each match, in the order the matches are found: from right to left when the regex uses RegexOptions.RightToLeft.
ReplaceAsync(Regex, string, Func<Match, CancellationToken, ValueTask<string>>, CancellationToken)
RegexExtensions.csReplaces all matches in the input string using an asynchronous replacement function.
public static ValueTask<string> ReplaceAsync(this Regex regex, string input, Func<Match, CancellationToken, ValueTask<string>> replacementFn, CancellationToken cancellationToken = default)Parameters
regexRegex- The regular expression.
inputstring- The string to search for a match.
replacementFnFunc<Match, CancellationToken, ValueTask<string>>- The function that computes the replacement of each match. It receives
cancellationToken. cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Remarks
The replacement function is called for each match, in the order the matches are found: from right to left when the regex uses RegexOptions.RightToLeft.
ReplaceAsync(Regex, string, Func<Match, Task<string>>)
RegexExtensions.csReplaces all matches in the input string using an asynchronous replacement function.
public static Task<string> ReplaceAsync(this Regex regex, string input, Func<Match, Task<string>> replacementFn)Parameters
regexRegexinputstringreplacementFnFunc<Match, Task<string>>
Returns
Remarks
The replacement function is called for each match, in the order the matches are found: from right to left when the regex uses RegexOptions.RightToLeft.
ReplaceAsync(Regex, string, Func<Match, Task<string>>, int, int, CancellationToken)
RegexExtensions.csReplaces at most count matches, searched from startat, in the input string using an asynchronous replacement function.
public static Task<string> ReplaceAsync(this Regex regex, string input, Func<Match, Task<string>> replacementFn, int count, int startat, CancellationToken cancellationToken = default)Parameters
regexRegex- The regular expression.
inputstring- The string to search for a match.
replacementFnFunc<Match, Task<string>>- The function that computes the replacement of each match.
countint- The maximum number of times the replacement can occur, or -1 to replace all the matches.
startatint- The character position in the input string where the search begins, as for
Regex.Replace. cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Remarks
The replacement function is called for each match, in the order the matches are found: from right to left when the regex uses RegexOptions.RightToLeft.
ReplaceAsync(Regex, string, Func<Match, Task<string>>, int, CancellationToken)
RegexExtensions.csReplaces at most count matches in the input string using an asynchronous replacement function.
public static Task<string> ReplaceAsync(this Regex regex, string input, Func<Match, Task<string>> replacementFn, int count, CancellationToken cancellationToken = default)Parameters
regexRegex- The regular expression.
inputstring- The string to search for a match.
replacementFnFunc<Match, Task<string>>- The function that computes the replacement of each match.
countint- The maximum number of times the replacement can occur, or -1 to replace all the matches.
cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Remarks
The replacement function is called for each match, in the order the matches are found: from right to left when the regex uses RegexOptions.RightToLeft.
ReplaceAsync(Regex, string, Func<Match, Task<string>>, CancellationToken)
RegexExtensions.csReplaces all matches in the input string using an asynchronous replacement function.
public static Task<string> ReplaceAsync(this Regex regex, string input, Func<Match, Task<string>> replacementFn, CancellationToken cancellationToken)Parameters
regexRegexinputstringreplacementFnFunc<Match, Task<string>>cancellationTokenCancellationToken
Returns
Remarks
The replacement function is called for each match, in the order the matches are found: from right to left when the regex uses RegexOptions.RightToLeft.