I need to select the text between two tags in a document
e.g.
<#introduction> text here
and insert it into a newly created document.
Can anyone help me with this?
Thanks
Hi
Thanks for your inquiry. If you need to select text only then you can use Replace evaluator to achieve this. Please see the following code:
public void Test167()
{
// Open document
Document doc = new Document(@"Test167\in.doc");
// Create regex
Regex regexFindPlaceholder = new Regex(@"<\#introduction>(?.*)");
// find and replace
doc.Range.Replace(regexFindPlaceholder, new ReplaceEvaluator(ReplaceEvalGetValue), false);
}
ReplaceAction ReplaceEvalGetValue(object sender, ReplaceEvaluatorArgs e)
{
string value = e.Match.Groups["value"].Value;
return ReplaceAction.Skip;
}
But I don’t think that using tags in the word document is a good idea. I think using bookmarks is most useful. Please see the following link; maybe information provided there could be useful for you.
https://forum.aspose.com/t/101379
Best regards.