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

Free Support Forum - aspose.com

Problem on Standard Example Find Replace


i’ve upgraded Aspose Words from version 13.3 to version 15.8. Find / Replace example does not work anymore.

The url of find/replace example is:

My source code and the word document are attached,

The result is

Exception in thread "main" java.lang.StringIndexOutOfBoundsException
at java.lang.AbstractStringBuilder.delete(AbstractStringBuilder.java:733)
at java.lang.StringBuilder.delete(StringBuilder.java:244)
at asposewobfuscated.zz68.zzX(Unknown Source)
at com.aspose.words.zz1E.zzZ(Unknown Source)
at com.aspose.words.zz1E.zzZNf(Unknown Source)
at com.aspose.words.Range.zzZ(Unknown Source)
at com.aspose.words.Range.replace(Unknown Source)
at test.Test.main(Test.java:15)

Hi Federico,

Thanks for your inquiry. Please use the value of isForward parameter of Range.replace method (Regex, IReplacingCallback, Boolean) method as false to fix this issue.

Please let us know if you have any more queries.

Document doc = new Document(MyDir + "TestFile.doc");
Pattern regex = Pattern.compile("your", Pattern.CASE_INSENSITIVE);
doc.getRange().replace(regex, new MyReplaceEvaluator(), true);