Find and not replace functionality seems odd

I want to look through a Word document and find all instances of a particular word. I don’t want to replace the word, I just want to know if it exists.

This page suggests Range.Replace “is useful for searching strings without replace”: https://docs.aspose.com/words/net/find-and-replace/

But this page says the return value is the “number of replacements made”: https://reference.aspose.com/words/net/aspose.words/range/replace/

I don’t want to replace anything, I just want to find search without replace. I can do that with the following code:

public class MergeCodeFinder : IReplacingCallback
{
    public ReplaceAction Replacing(ReplacingArgs args)
    {
        args.Replacement = args.Replacement;
        return ReplaceAction.Replace;
    }
}

Setting args.Replacement = args.Replacement just to get the count of “replacements” seems a bit silly. Am I missing something? Is there an easier way to find something in a document without replacing it?

Hello

Thanks for your request. If you need to find keywords in document’s content, of course you can use Range.Replace method. For example, see the following article:
https://docs.aspose.com/words/net/find-and-replace/
Hope this helps.
Best regards,

Hi Allen,
Thanks for your inquiry.
More specifically, you can use Range.Replace just to find text and not replace them by returning return ReplaceAction.Skip; instead.
This will skip any replacement at all.
Thanks,