ReplacerContext.SetReplacement
ReplacerContext SetReplacement method. Sets pattern and replacement used by find/replace operation.
SetReplacement(string, string)
Sets pattern and replacement used by find/replace operation.
public void SetReplacement(string pattern, string replacement)
Remarks
Using this method overrides previously set pattern and replacement.
Examples
Shows how to configure find/replace options to ignore matches in particular document elements.
ReplacerContext context = new ReplacerContext();
context.SetReplacement("findme", "Replacement Text");
context.FindReplaceOptions.IgnoreDeleted = true;
context.FindReplaceOptions.IgnoreFieldCodes = true;
context.FindReplaceOptions.IgnoreFields = true;
context.FindReplaceOptions.IgnoreFootnotes = true;
context.FindReplaceOptions.IgnoreInserted = true;
context.FindReplaceOptions.IgnoreShapes = true;
context.FindReplaceOptions.IgnoreStructuredDocumentTags = true;
Replacer.Create(context)
.From(MyDir + "Replacing.docx")
.To(ArtifactsDir + "Replacer.FindReplaceOptionsIgnore.docx")
.Execute();
See Also
- class ReplacerContext
- namespace Wordize.Replacing
- assembly Wordize
SetReplacement(Regex, string)
Sets pattern and replacement used by find/replace operation.
public void SetReplacement(Regex pattern, string replacement)
Remarks
Using this method overrides previously set pattern and replacement.
Examples
Shows how to perform find/replace operation using fluent API.
ReplacerContext context = new ReplacerContext();
context.SetReplacement(new Regex(@"[a-zA-Z]{6}\d+"), "Replacement Text");
Replacer.Create(context)
.From(MyDir + "Replacing.docx")
.To(ArtifactsDir + "Replacer.ReplacerContext.docx")
.Execute();
See Also
- class ReplacerContext
- namespace Wordize.Replacing
- assembly Wordize