| TextRangeFindText Method (String, Int32, RangeMatchType) |
Searches up to count characters for the text given by text.
The starting position and direction are also specified by count,
and the matching criteria are given by flags.
Namespace: TextObjectModelAssembly: ManagedTOM2 (in ManagedTOM2.dll) Version: 1.0.5577.41188
Syntax public int FindText(
string text,
int count,
[OptionalAttribute] RangeMatchType flags
)
Public Function FindText (
text As String,
count As Integer,
<OptionalAttribute> flags As RangeMatchType
) As Integer
public:
int FindText(
String^ text,
int count,
[OptionalAttribute] RangeMatchType flags
)
Parameters
- text
- Type: SystemString
String to find. - count
- Type: SystemInt32
Maximum number of characters to search. - flags (Optional)
- Type: TextObjectModelRangeMatchType
Flags governing comparisons.
Return Value
Type:
Int32The length of string matched.
Examples
The following example demonstrates how to find text in a range:
void FindTextExample(TextDocument document) {
TextRange range = document.EntireRange;
range.Text = "This is my first. This is my second.";
int result;
result = range.FindText("my");
if (result > 0)
Console.WriteLine("Substring found at position {0}", range.Start);
else
Console.WriteLine("Substring not found");
range.Expand(TextUnit.Story);
result = range.FindText("my", 6);
if (result > 0)
Console.WriteLine("Substring found at position {0}", range.Start);
else
Console.WriteLine("Substring not found");
}
See Also