Substitute text in document with a bookmark

Hello,

I want to substitute the first occurrance of “xxxxxx” with a bookmark.

I used the replace function with the replace evaluator.

When I have a match I use DocumentBuilder.MoveTo(e.MatchNode).

Then I do StartBookMark(),Write,EndBookMark.

Then I replace “xxxxxxx” with nothing.

This works great until “xxxxxxx” is found at a certain offset in the Node.

The bookmark gets placed at the start of the node.

I want to place it exactly at the MatchOffset in the Node.

Resume:
In the node “hello xxxxxxx this and that”.

My Bookmark subsituter makes it : "[bookmark]hello this and that"

While I want : "hello [bookmark] this and that"

Can anyone help me with this ?

Hi

Thanks for your inquiry. You should split the matched node in this case. You should use the same technique as described in the following article:
https://docs.aspose.com/words/net/find-and-replace/
Hope this helps.
Best regards.

Thanks i’ll try that.