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

Free Support Forum - aspose.com

Aspose words document.getRange().replace() not replacing line ending dot

I am processing an RTF document to do some find and replace operations using aspose words. For this purpose i am using the function document.getRange().replace() . It works fine in all cases except in replacing line ending dot (.). For example i am trying to replace N.V. with NV but it just replaces one dot and i have NV. as an output

Thd code i tried was

newdoc.getRange().replace("N.V.", "NV", false, true);


newdoc.getRange().replace(".", "", false, true);


Thanks for your inquiry. Please use the following code to achieve this:
Document doc = new Document(getMyDir() + “Test_Input.rtf”);

Pattern regex = Pattern.compile(“N.V.”, Pattern.CASE_INSENSITIVE);
doc.getRange().replace(regex, “NV”);

doc.save(getMyDir() + “out.rtf”);

I hope, this helps.

Best regards,