Free Support Forum - aspose.com

Range.replace() deprecation in Java

In my Java code I’m trying to find some text and process its Run node in a handler. I found some solutions in this topic based on Range.replace().

I’m using this method and it works just fine, BUT the method is marked as deprecated in your .jar. In your API documentation I see no mention of this deprecation. Can you tell me which alternative I should use?

So it’s about class com.aspose.words.Range and method: int replace(Pattern pattern, IReplacingCallback handler, boolean isForward)

In the handler I want to process the node found myself, and then I return ‘STOP’, so I only need the first hit (searching from end of document to front).

@fhoeben

Thanks for your inquiry. Please use one of the following method of Range class. We suggest you please read the following article.
Find and Replace

replace(java.util.regex.Pattern pattern, java.lang.String replacement, FindReplaceOptions options)
replace(java.lang.String pattern, java.lang.String replacement, FindReplaceOptions options)

Thanks. I hadn’t found the IReplacingCallback in FindReplaceOptions, maybe a good idea to also add the deprecation to https://apireference.aspose.com/java/words/com.aspose.words/Range, and a pointer to the article…

@fhoeben

Thanks for your inquiry. We will update the deprecated APIs. Please check the code examples in the following article.
Find and Replace