Extract text from a paragraph

Hi,

Below is my requirement:

  • I have a paragraph and i need to search for a particular text in the current paragraph.
  • If current paragraphs contains my search text i need to extract the matched text and move it to next line. i.e. create a new paragraph and move the matched text to the newly created paragraph.
  • Also please note that i need to retain all the formatting.

Thanks
Timothy

This message was posted using Page2Forum from Aspose.Words for .NET - Documentation

Hello
Thanks for your inquiry. I think in your case you can try using IReplacingCallback. Please see the following link for more information:
https://reference.aspose.com/words/net/aspose.words.replacing/ireplacingcallback/
Please let me know in case of any issues. I will be glad to help you.
Best regards,

Hi ,
Thanks for your quick response.
‘’’ NOTE: This is a simplistic method that will only work well when the match
‘’’ starts at the beginning of a run.

That is where the problem lies. We need to implement something like split the run
and get only matched text with all formatting.

So can you please help me out.

Thanks
Timothy

Hi
Thanks for your inquiry. Here you can find extended version of IReplacingCallback implementation, which will allow you to achieve what you need:
https://forum.aspose.com/t/61893
Hope this helps.
Best regards,