[]
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:
To search for text with certain formatting, use options
and set the FormattingOptions on it accordingly.
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
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 |
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. |
Type | Description |
---|---|
int | The number of replaced occurrences. |