Compartir a través de


TextBuffer.find Method

Definition

Overloads

find(String, Int32)
find(String)

Searches the TextBuffer object for any occurrence of a string expression.

find(String, Int32)

public:
 virtual bool find(System::String ^ _searchText, int _start);
public virtual bool find (string _searchText, int _start);
abstract member find : string * int -> bool
override this.find : string * int -> bool
Public Overridable Function find (_searchText As String, _start As Integer) As Boolean

Parameters

_searchText
String

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.

_start
Int32

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.

Returns

Applies to

find(String)

Searches the TextBuffer object for any occurrence of a string expression.

public:
 virtual bool find(System::String ^ text1);
public virtual bool find (string text1);
abstract member find : string -> bool
override this.find : string -> bool
Public Overridable Function find (text1 As String) As Boolean

Parameters

text1
String

Returns

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.

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; 
}

Applies to