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

Free Support Forum - aspose.com

Replacing strings including the characters "«»"

I'm currently using espose to replace elements in a doc document with their respective values. The elements are identified by the fact that they are enclosed between "«»" characters.

unfortunately it seems that my code doesn't work when I'm using such characters. could someone help me with this problem? my code is along the lines of

DocHandlerInterface docHandler


boolean esito=docHandler.loadDocument(documentAsStream);

docHandler.replace("«PROVA»", "proviamo", false, true);

which fails to replace the string "«PROVA»" with "proviamo", even though replacing the last line with

docHandler.replace("PROVA", "proviamo", false, true);

does correctly result in the string "«proviamo»" (that is: the replace mechanism works correctly, as long as the chacacters "«»" are not part of string to be replaced.

Could you help me with this problem? Is it possible to make the replace accept this characters? A search in the forum archives resulted in the thread http://www.aspose.com/community/forums/131075/not-able-to-replace-data-containing-special-characters/showthread.aspx#131075 with the scary quote " You can’t replace special character. This is by design." but then goes on pointing out that it refers to "paragraph break, cell break, section break, field start, field separator, field end, inline picture, drawing object, footnote" which shouldn't be the case with my problem


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for you rinquiry. Please try using the following code:

doc.getRange().replace("«PROVA»", "proviamo", false, false);

Hope this helps. Also, if you need to fill the document with data, I do not think that find/replace is the best option. I think the best option in this case is Mail Merge:


Best regards.

yay! it works. Thanks.

(I'll also see into Mail Merge, but meanwhile I'm happy of at least having this working)