Method ReplaceRegex
ReplaceRegex(DomNode, string, string, FindOptions?, ReplaceOptions?)
Replaces every match of a regular expression. The replacement may use the usual substitution syntax ("\(1", "\){name}").
public static int ReplaceRegex(this DomNode root, string pattern, string replacement, FindOptions? options = null, ReplaceOptions? replaceOptions = null)
Parameters
rootDomNodeThe document or subtree to edit.
patternstringThe pattern.
replacementstringThe replacement, with substitutions.
optionsFindOptionsThe search options, or null for the defaults. The regex timeout is enforced.
replaceOptionsReplaceOptionsThe replacement options, or null for the defaults.
Returns
- int
The number of replacements made.
Exceptions
- ArgumentNullException
An argument is null.
- ArgumentException
The pattern is not a valid regular expression.
- RegexMatchTimeoutException
A match attempt exceeded RegexTimeout.