Share via


IVsFindHelper.FindInText Method

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)

Syntax

'Declaration
Function FindInText ( _
    pszFind As String, _
    pszReplace As String, _
    grfFindOptions As UInteger, _
    grfBufferFlags As UInteger, _
    cchText As UInteger, _
    pchText As UShort(), _
    <OutAttribute> ByRef piFound As UInteger, _
    <OutAttribute> ByRef pcchFound As UInteger, _
    <OutAttribute> ByRef pbstrReplaceText As String, _
    <OutAttribute> ByRef pfFound As Integer _
) As Integer
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
)
int FindInText(
    [InAttribute] String^ pszFind, 
    [InAttribute] String^ pszReplace, 
    [InAttribute] unsigned int grfFindOptions, 
    [InAttribute] unsigned int grfBufferFlags, 
    [InAttribute] unsigned int cchText, 
    [InAttribute] array<unsigned short>^ pchText, 
    [OutAttribute] unsigned int% piFound, 
    [OutAttribute] unsigned int% pcchFound, 
    [OutAttribute] String^% pbstrReplaceText, 
    [OutAttribute] int% pfFound
)
abstract FindInText : 
        pszFind:string * 
        pszReplace:string * 
        grfFindOptions:uint32 * 
        grfBufferFlags:uint32 * 
        cchText:uint32 * 
        pchText:uint16[] * 
        piFound:uint32 byref * 
        pcchFound:uint32 byref * 
        pbstrReplaceText:string byref * 
        pfFound:int byref -> int
function FindInText(
    pszFind : String, 
    pszReplace : String, 
    grfFindOptions : uint, 
    grfBufferFlags : uint, 
    cchText : uint, 
    pchText : ushort[], 
    piFound : uint, 
    pcchFound : uint, 
    pbstrReplaceText : String, 
    pfFound : int
) : int

Parameters

  • 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.

  • 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.

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:

.NET Framework Security

See Also

Reference

IVsFindHelper Interface

Microsoft.VisualStudio.TextManager.Interop Namespace