Table of Contents

Method ReplaceRegex

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

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

root DomNode

The document or subtree to edit.

pattern string

The pattern.

replacement string

The replacement, with substitutions.

options FindOptions

The search options, or null for the defaults. The regex timeout is enforced.

replaceOptions ReplaceOptions

The 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.