FindReplaceOptions.UseSubstitutions

FindReplaceOptions UseSubstitutions property. Gets or sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false.

FindReplaceOptions.UseSubstitutions property

Gets or sets a boolean value indicating whether to recognize and use substitutions within replacement patterns. The default value is false.

public bool UseSubstitutions { get; set; }

Remarks

For the details on substitution elements please refer to: https://docs.microsoft.com/en-us/dotnet/standard/base-types/substitutions-in-regular-expressions.

Examples

Shows how to replace text in the document loaded from stream using customized find/replace options.

FindReplaceOptions options = new FindReplaceOptions();
options.UseSubstitutions = true;

using (Stream input = File.OpenRead(MyDir + "Replacing.docx"))
using (Stream output = File.Create(ArtifactsDir + "Replacer.Replace2.docx"))
{
    int replacements = Replacer.Replace(input, output, SaveFormat.Docx, "findme", "We Replaced \"$0\" Text", options);
}

See Also