Compartir a través de


IVsFindHelper.FindInText Method

Definition

Finds, and optionally replaces, a text pattern in a text string.

public:
 int FindInText(System::String ^ pszFind, System::String ^ pszReplace, System::UInt32 grfFindOptions, System::UInt32 grfBufferFlags, System::UInt32 cchText, cli::array <System::UInt16> ^ pchText, [Runtime::InteropServices::Out] System::UInt32 % piFound, [Runtime::InteropServices::Out] System::UInt32 % pcchFound, [Runtime::InteropServices::Out] System::String ^ % pbstrReplaceText, [Runtime::InteropServices::Out] int % pfFound);
int FindInText(std::wstring const & pszFind, std::wstring const & pszReplace, unsigned int grfFindOptions, unsigned int grfBufferFlags, unsigned int cchText, std::Array <unsigned short> const & pchText, [Runtime::InteropServices::Out] unsigned int & piFound, [Runtime::InteropServices::Out] unsigned int & pcchFound, [Runtime::InteropServices::Out] std::wstring const & & pbstrReplaceText, [Runtime::InteropServices::Out] int & pfFound);
public int FindInText (string pszFind, string pszReplace, uint grfFindOptions, uint grfBufferFlags, uint cchText, ushort[] pchText, out uint piFound, out uint pcchFound, out string pbstrReplaceText, out int pfFound);
abstract member FindInText : string * string * uint32 * uint32 * uint32 * uint16[] * uint32 * uint32 * string * int -> int
Public Function FindInText (pszFind As String, pszReplace As String, grfFindOptions As UInteger, grfBufferFlags As UInteger, cchText As UInteger, pchText As UShort(), ByRef piFound As UInteger, ByRef pcchFound As UInteger, ByRef pbstrReplaceText As String, ByRef pfFound As Integer) As Integer

Parameters

pszFind
String

[in] Text pattern to find.

pszReplace
String

[in] Replacement text pattern.

grfFindOptions
UInt32

[in] Search options. Values are taken from the __VSFINDOPTIONS enumeration.

grfBufferFlags
UInt32

[in] Flag indicating that pchText begins or ends a line. Values are taken from the __VSFINDBUFFERFLAGS enumeration.

cchText
UInt32

[in] Size of text, in Unicode characters.

pchText
UInt16[]

[in, size_is(cchText)] Text buffer to search for pszFind.

piFound
UInt32

[out] Index in buffer pointing to match.

pcchFound
UInt32

[out] Length of match found.

pbstrReplaceText
String

[out] Computed replacement text, if necessary.

pfFound
Int32

[out, retval] true if pattern was found.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textfind.idl:

HRESULT IVsFindHelper::FindInText(  
   [in] LPCOLESTR pszFind,  
   [in] LPCOLESTR pszReplace,  
   [in] VSFINDOPTIONS grfFindOptions,  
   [in] VSFINDBUFFERFLAGS grfBufferFlags,  
   [in] ULONG cchText,  
   [in,size_is(cchText)] LPCOLESTR pchText,  
   [out] ULONG * piFound,  
   [out] ULONG * pcchFound, [out] BSTR * pbstrReplaceText  
);  

An IVsFindHelper interface pointer is passed to Find and Replace. If you want to support wildcards, regular expressions, or whole words, use FindInText to do your string matching so that all the options and behavior work consistently with the Visual Studio editor.

Computed replacement text is returned in pbstrReplaceText.

Computed replacement text is necessary in the following conditions:

Applies to