Table of Contents

Class FindReplaceExtensions

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

Plain and regular-expression find and replace over document text, preserving formatting.

What a match may cross. A match lives inside one paragraph and may span any number of runs, whatever their formatting — that is the whole point, since Word splits a sentence into runs for reasons that have nothing to do with its words. It may also cross bookmark markers, which are zero-width annotations. It may not cross a field character, field instruction text, a hyperlink boundary, a break, an image, a shape, a note reference, a content control or preserved unknown markup. Those carry a target, an instruction or content of their own, and text spliced across one of them would either change what the field or link means or be silently discarded the next time the field is updated.

Revisions. Searching sees the same text GetText(DomNode, RevisionView) reports for Final: deleted runs are not searchable, inserted runs are. A replacement inherits the revision mark of the run the match started in, so replacing inside tracked-inserted text stays tracked-inserted.

Ordering. Matches are returned in document order and never overlap: scanning resumes at the end of each match. Zero-length regular-expression matches are skipped — they identify no content to replace and would not terminate.

public static class FindReplaceExtensions
Inheritance
FindReplaceExtensions
Inherited Members

Methods

FindRegex(DomNode, string, FindOptions?)

Finds every match of a regular expression.

FindText(DomNode, string, FindOptions?)

Finds every occurrence of a literal string.

ReplaceRegex(DomNode, string, string, FindOptions?, ReplaceOptions?)

Replaces every match of a regular expression. The replacement may use the usual substitution syntax ("\(1", "\){name}").

ReplaceText(DomNode, string, string, FindOptions?, ReplaceOptions?)

Replaces every occurrence of a literal string.