DOM.Elements.TextElements.Text
Represents a text within the document model. Anode holds plain textual content and an optional text style, and can participate in search, replace, and other text-processing operations.
6 members
Constructors
Text
2 overloadsText()Initializes a new instance of theclass with empty content.
Text(string text)Initializes a new instance of theclass with the specified content.
Parameters
- text
- The initial text to populate the content with.
Properties
Gets or sets the literal textual content contained in this text run.
Gets or sets the style applied to this text run. The style defines font characteristics such as size, weight, color, and other inline formatting properties.
Methods
Find
Find(string searchText, RegexOptions? regexOption, bool wholeWordOnly, bool caseSensitive)Finds all occurrences of the specified search text within the current text content. Supports optional regular expression behavior, whole-word matching, and case-sensitivity controls. Returns a list of character indices where matches occur.
Parameters
- searchText
- The text to search for. Cannot be null.
- regexOption
- Optional to apply.
- wholeWordOnly
- When, the match must correspond to a complete whole word boundary.
- caseSensitive
- When, the search is case-sensitive; otherwise performed case-insensitively.
Returns
A list of integer indices representing the starting positions of each match.
Exceptions
- System.ArgumentNullException: Thrown whenis null.
Replace
IText Replace(string searchText, string replaceText, RegexOptions? regexOption, bool wholeWordOnly, bool caseSensitive)Replaces occurrences of the specified search text within the current text content. Supports optional regular expression behavior, whole-word matching, and case-sensitivity controls.
Parameters
- searchText
- The text to search for. Cannot be null.
- replaceText
- The replacement text to substitute in matched positions.
- regexOption
- Optional to apply.
- wholeWordOnly
- When, the match must correspond to a complete whole word boundary.
- caseSensitive
- When, the search is case-sensitive; otherwise performed case-insensitively.
Returns
IText
Returns the currentinstance to allow fluent chaining.
Exceptions
- System.ArgumentNullException: Thrown whenis null.