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

Free Support Forum - aspose.com

Need info on Replace method

I have a requirement here. In the attached doc you can find few contents in between < and > like

0 0 1 1 10 Intuit 1 1 10 14.0 String label; // e.g Invoice
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”> String key; // e.g
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>}
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>So the list should contain list of data.
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>If there is no label presents then label should be null. Basically I need to find the individual matching string with the previous node.
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>
<span style=“font-size:12.0pt;font-family:Cambria;
mso-ascii-theme-font:minor-latin;mso-fareast-font-family:“MS 明朝”;mso-fareast-theme-font:
minor-fareast;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>Please let me know how it is possible.

Hi Abhradeep,

Thanks for your inquiry. You can achieve your requirement by implementing IReplacingCallback interface. Please use the same approach shared at following documentation link to achieve your requirements.
http://www.aspose.com/docs/display/wordsjava/How+to++Find+and+Highlight+Text

Could you please share your expected output document here for our reference? We will then provide you more information about your query.

Let me know how to get the previous word of the matched word?

If possible can you please let me know what is the problem with this attached code? why it is giving class cast exception



Thanks I have corrected the problem myself. Thanks for your effort though

Hi Abhradeep,

Thanks for your feedback. It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.