Back to Text
FindMethod
Definition
- Namespace
- DOM.Elements.TextElements
- Assembly
- DOM.dll
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.
Find(string searchText, RegexOptions? regexOption, bool wholeWordOnly, bool caseSensitive)Parameters
- searchText
- The text to search for. Cannot be null.
- regexOption
- Optional to apply. RegexOptions
- 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 when is null. searchText
Examples
csharp
1var t = new Text("apple orange apple banana apple");
2var indices = t.Find("apple", caseSensitive: true);
3// indices == [0, 13, 27]
4