TextBuffer.find Method
Searches the TextBuffer object for any occurrence of a string expression.
Syntax
public boolean find(str searchText, [int start])
Run On
Called
Parameters
- searchText
Type: str
The string expression to search for.
- start
Type: int
A numeric expression that sets the starting position for each search; optional. If this parameter is omitted, the search starts at the first character position.
Return Value
Type: boolean
true if searchText is found; otherwise, false.
Remarks
This method performs a textual, case-insensitive comparison by using regular expressions. For more information, see the match function.
Case-insensitivity can be turned off by using the ignoreCase method.
Regular expressions can be turned off by using the regularExpressions method.
Examples
The following example searches the TextBuffer object for all occurrences of a specified string and prints the position at which the match is found.
int pos;
TextBuffer textBuffer;
textBuffer = new TextBuffer();
textBuffer.setText("ABC DEF GHI JKL MNO ABC ABC");
pos = 0;
while (textBuffer.find("ABC",pos))
{
print "String found at position: ", textBuffer.matchPos();
pause;
pos = textBuffer.matchPos()+1;
}