[]
        
(Showing Draft Content)

GrapeCity.Documents.Word.RangeBaseFindReplaceExtensions.Replace

Replace Method

Replace(RangeBase, string, string, FindReplaceOptions)

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 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:

  • &pend of paragraph
  • &lmanual line break
  • &mpage break
  • &bsection break

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

Declaration
public static int Replace(this RangeBase searchRange, string findPattern, string replaceText, FindReplaceOptions options = null)
Public Shared Function Replace(searchRange As RangeBase, findPattern As String, replaceText As String, Optional options As FindReplaceOptions = Nothing) As Integer
Parameters
Type Name Description
RangeBase searchRange

The current range.

string 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 FormattingOptions passed in options.

string replaceText

The replacement text.

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

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

The search and replace options.

Returns
Type Description
int

The number of replaced occurrences.