[]
Provides find/replace extension methods for the RangeBase class.
public static class RangeBaseFindReplaceExtensions
In the current range, finds all occurrences of a specified findPattern
,
using specified options
.
The findPattern
can contain regular expressions
(use RegularExpressions to control this).
The following special tokens can be used in the findPattern
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 IEnumerable<FindResult> Find(this RangeBase searchRange, string findPattern, FindOptions options = null)
searchRange
RangeBaseThe current range.
findPattern
stringThe 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
.
options
FindOptionsThe search and replace options.
The list of found occurrences.
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)
searchRange
RangeBaseThe current range.
findPattern
stringThe 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
.
replaceText
stringThe 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.options
FindReplaceOptionsThe search and replace options.
The number of replaced occurrences.