IVsFindHelper::FindInText Method (String^, String^, UInt32, UInt32, UInt32, array<UInt16>^, UInt32, UInt32, String^, Int32)

 

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

Namespace:   Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop (in Microsoft.VisualStudio.TextManager.Interop.dll)

int FindInText(
	String^ pszFind,
	String^ pszReplace,
	unsigned int grfFindOptions,
	unsigned int grfBufferFlags,
	unsigned int cchText,
	array<unsigned short>^ pchText,
	[OutAttribute] unsigned int% piFound,
	[OutAttribute] unsigned int% pcchFound,
	[OutAttribute] String^% pbstrReplaceText,
	[OutAttribute] int% pfFound
)

Parameters

pszFind
Type: System::String^

[in] Text pattern to find.

pszReplace
Type: System::String^

[in] Replacement text pattern.

grfFindOptions
Type: System::UInt32

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

grfBufferFlags
Type: System::UInt32

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

cchText
Type: System::UInt32

[in] Size of text, in Unicode characters.

pchText
Type: array<System::UInt16>^

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

piFound
Type: System::UInt32

[out] Index in buffer pointing to match.

pcchFound
Type: System::UInt32

[out] Length of match found.

pbstrReplaceText
Type: System::String^

[out] Computed replacement text, if necessary.

pfFound
Type: System::Int32

[out, retval] true if pattern was found.

Return Value

Type: System::Int32

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

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:

Return to top
Show: