Find the whole word

@priyanga
This code also match contain of search text.
If i want’s to match hello.Its match hello and hello123 and 123hello. I need exact match count.
in this code its return 3 match.but i need 1 match where its match exactly.

@tahir.manzoor
This code also match contain of search text.
If i want’s to match hello.Its match hello and hello123 and 123hello. I need exact match count.
in this code its return 3 match.but i need 1 match where its match exactly.

@rabin.samanta

Thanks for your inquiry. Please use FindReplaceOptions.FindWholeWordsOnly property as shown below to get the desired output.

Document doc = new Document(MyDir + "in.docx");
FindReplaceOptions findReplaceOptions = new FindReplaceOptions();
findReplaceOptions.setFindWholeWordsOnly(true);

FindFigureCaption callback = new FindFigureCaption();
findReplaceOptions.setReplacingCallback(callback);
doc.getRange().replace("Figure", "", findReplaceOptions);

System.out.println(callback.mMatchNumber);

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