Replace function with range is not working properly in Aspose words Java V17.6

Hi ,
We are using Aspose words java v 17.6.
While converting word document to a text., we are trying to replace bolded segments ,italic segments and bold & italic segments with the corresponding tags before and after the segment.
We are trying to use the below.,for replacing that text.
run.getrange().replace(oldvalue,newvalue,true,true)
But the replacement is happening for all the occurences only few are getting replaced.
I am attaching the JavaScript code and RTF document, for your refernce.
Can you please look into this issue and advice?
Aspose_Test_docs.zip (4.8 KB)

Awaiting your response.
Thanks in advance.

@mjagatha,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for Java 17.10 with following code example. We have not found any issue with output document. Please use Aspose.Words for Java 17.10. We have attached the output document with this post for your kind reference.
output.zip (3.4 KB)

Document doc = new Document(MyDir + "109500_Default_2730_110513113604012.rtf");
for (Node node : doc.getChildNodes(NodeType.RUN, true).toArray()) {
    Run run = (Run)node;
    if (run.getFont().getBold() && run.getFont().getItalic()) {
        String match = "";
        match = run.getRange().getText();
        int x = run.getRange().replace(match, "\\ZHI\\" + match+"\\N\\", new FindReplaceOptions());
        System.out.println("Italic and bold replaced  "+x);
    }
    if(run.getFont().getBold() && !run.getFont().getItalic())
    {
        String match= run.getText();
        int  x = run.getRange().replace(match, "\\H\\"+ match+"\\N\\", new FindReplaceOptions());
        System.out.println(" bold stmt replaced "+x);
    }
    if(!run.getFont().getBold() && run.getFont().getItalic()){
        String match= run.getText();
        match = run.getText();
        int x =  run.getRange().replace(match, "\\ZI\\" + match+"\\N\\", new FindReplaceOptions());
        System.out.println("Italic stmt replaced  "+x);
    }

}
doc.save(MyDir + "output.txt");