[]
        
(Showing Draft Content)

GrapeCity.Documents.Word.RangeBaseFindReplaceExtensions

Class RangeBaseFindReplaceExtensions

Namespace
GrapeCity.Documents.Word
Assembly
GcDocs.Word.dll

Provides find/replace extension methods for the RangeBase class.

public static class RangeBaseFindReplaceExtensions
Inheritance
object
RangeBaseFindReplaceExtensions
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Methods

Find(RangeBase, string, FindOptions)

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:

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

public static IEnumerable<FindResult> Find(this RangeBase searchRange, string findPattern, FindOptions options = null)

Parameters

searchRange RangeBase

The current range.

findPattern string

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.

options FindOptions

The search and replace options.

Returns

System.Collections.Generic.IEnumerable<T><FindResult>

The list of found occurrences.

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.

public static int Replace(this RangeBase searchRange, string findPattern, string replaceText, FindReplaceOptions options = null)

Parameters

searchRange RangeBase

The current range.

findPattern string

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.

replaceText string

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.
options FindReplaceOptions

The search and replace options.

Returns

int

The number of replaced occurrences.