We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Find and print the specific word

Hi Team,

I want to find and print the number of occurrences of specific string in word document using aspose.words in java.

I want to search the word “FIGURE” in whole document and print the number of occurrences.

please kindly help me to solve the same issue.

Thanks & Regards,
priyanga G


Thanks for your inquiry. Please use the following code example to get the desired output.

Document doc = new Document(MyDir + "in.docx");
FindReplaceOptions findReplaceOptions = new FindReplaceOptions();
FindFigureCaption callback = new FindFigureCaption();
doc.getRange().replace("Figure", "", findReplaceOptions);


class FindFigureCaption implements IReplacingCallback {
    public int mMatchNumber;
    public int replacing(ReplacingArgs e) throws Exception {
        return ReplaceAction.SKIP;

Hi @tahir.manzoor,

Thanks a lot.

Its working fine.

Thanks &regards,
Priyanga G


Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

2 posts were split to a new topic: Find the whole word