Aspose.word How to stop a replace operation

Hello,

I want to search for a text in my document and memorize the three firts occurences only.

To do so i implemented the IReplacingCallback interface and count each match so that i will only memorize (ie add then into a list) the three first matches and use this callback with the replace operation.

The problem with this method is that the replace operation still continues even though i already got what i was looking for.

Is there a way to stop the replace operation sooner ?

Sincerely.

@aaronArchest You can use ReplaceAction.Stop in IReplacingCallback to terminate the replace operation.

1 Like