Documents for Word, .NET Edition
GrapeCity.Documents.Word Assembly / GrapeCity.Documents.Word Namespace / RangeBaseFindReplaceExtensions Class / Replace Method
The current range.
The search pattern. May contain regular expressions, or be an empty string.

If empty, the search will be for any text with formatting that matches the FindOptions.FormattingOptions passed in options.

The replacement text.

If empty, the found text will be removed. FindReplaceOptions.ReplacingCallback can still be used to provide a replacement string.

If null, no replacement will occur, but FindReplaceOptions.ReplacingCallback and FindReplaceOptions.ReplacedCallback will still be called.
The search and replace options.

In This Topic
    Replace Method
    In This Topic
    In the current range, searches for a specified findPattern, and replaces it with a provided replaceText, using specified options.

    The findPattern can contain regular expressions (use FindOptions.RegularExpressions to control this).

    The following special tokens can be used in the findPattern and in the replaceText regardless of whether regex are on or off:

    • end of paragraph
    • manual line break
    • page break
    • section break

    To search for text with certain formatting, use options and set the FindOptions.FormattingOptions on it accordingly.

    Syntax
    'Declaration
     
    Public Shared Function Replace( _
       ByVal searchRange As RangeBase, _
       ByVal findPattern As System.String, _
       ByVal replaceText As System.String, _
       Optional ByVal options As FindReplaceOptions _
    ) As System.Integer
    public static System.int Replace( 
       RangeBase searchRange,
       System.string findPattern,
       System.string replaceText,
       FindReplaceOptions options
    )

    Parameters

    searchRange
    The current range.
    findPattern
    The search pattern. May contain regular expressions, or be an empty string.

    If empty, the search will be for any text with formatting that matches the FindOptions.FormattingOptions passed in options.

    replaceText
    The replacement text.

    If empty, the found text will be removed. FindReplaceOptions.ReplacingCallback can still be used to provide a replacement string.

    If null, no replacement will occur, but FindReplaceOptions.ReplacingCallback and FindReplaceOptions.ReplacedCallback will still be called.
    options
    The search and replace options.

    Return Value

    The number of replaced occurrences.
    See Also