Hi Ahmet,
Thanks for your query. Yes, you can achieve your requirement by implementing
IReplacingCallback interface. Please use the same approach shared at following documentation link to find tags like <@Product Code> and <@Product Name>.
Please also read the following ariticle about 'Find and Replace' and check following code snippet for your kind refernece.
Document doc = new
Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Regex regex = new Regex("\\<@",
RegexOptions.IgnoreCase);
FindEval obj = new
FindEval();
doc.Range.Replace(regex, obj, true);
foreach (Run run in obj.nodes)
{
Console.WriteLine(run.Text);
public class FindEval : IReplacingCallback
{
//Store Matched nodes
public ArrayList
nodes = new ArrayList();
ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
// This is a Run node that contains either the beginning or
the complete match.
Node currentNode = e.MatchNode;
nodes.Add(currentNode);
return ReplaceAction.Skip;
}
}
Hope this helps you. Please let us know if you have any more queries.