ReplaceAction Enumeration |
Allows the user to specify what happens to the current match during a replace operation.
Namespace:
Aspose.Words.Replacing
Assembly:
Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntaxpublic enum ReplaceAction
Public Enumeration ReplaceAction
public enum class ReplaceAction
Members
| Member name | Value | Description |
---|
| Replace | 0 |
Replace the current match.
|
| Skip | 1 |
Skip the current match.
|
| Stop | 2 |
Terminate the replace operation.
|
Remarks
ExamplesShows how to insert content of one document into another during a customized find and replace operation.
public void InsertDocumentAtReplace()
{
Document mainDoc = new Document(MyDir + "Document insertion destination.docx");
FindReplaceOptions options = new FindReplaceOptions();
options.Direction = FindReplaceDirection.Backward;
options.ReplacingCallback = new InsertDocumentAtReplaceHandler();
mainDoc.Range.Replace(new Regex("\\[MY_DOCUMENT\\]"), "", options);
mainDoc.Save(ArtifactsDir + "InsertDocument.InsertDocumentAtReplace.doc");
}
private class InsertDocumentAtReplaceHandler : IReplacingCallback
{
ReplaceAction IReplacingCallback.Replacing(ReplacingArgs args)
{
Document subDoc = new Document(MyDir + "Document.docx");
Paragraph para = (Paragraph) args.MatchNode.ParentNode;
InsertDocument(para, subDoc);
para.Remove();
return ReplaceAction.Skip;
}
}
See Also