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

Free Support Forum - aspose.com

Deleting portions of a document

I am interested in removing segments of a template document. In other words, if my document contains the following info:

{my_id}
Some title
Here is some text in the document.
{/my_id}

I would like to be able to remove all text between the {my_id} and {/my_id}.

Does anyone have some sample code that might accomplish this? Or is there some other strategy that might accomplish the same thing?

Thanks for your help.

Hi

Thanks for your inquiry. There is no direct way to achieve this, however, it is possible to achieve. You can try using code provided here:
https://forum.aspose.com/t/range-replace-regex/67656
Also, if you have control over your document, you can use bookmark instead of placeholders. In case of using bookmarks, you can remove its content by simply clearing its text.

doc.Range.Bookmarks["myBookmark"].Text = "";

Best regards.