Hi Ajeesh,
Thanks for your inquiry. In your case, i will suggest you following code snippet:
Document doc = new Document("D:/temp/input.docx");
Regex regex = new Regex(@"(?~#(.*?)~#%)", RegexOptions.IgnoreCase);
doc.Range.Replace(regex, new InsertDocumentAtReplaceHandler(), true);
doc.Save("D:/temp/Out.docx");
public class InsertDocumentAtReplaceHandler : IReplacingCallback
{
ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
String title = e.Match.Groups["title"].Value.Trim();
//Pass title variable to interpret translator
Int32 value = //get it from database
if(value>=0)
e.Replacement = value.ToString();//"ReplaceTitleString";
else
e.Replacement = "(" +
value.ToString() + ")";
e.Replacement = i.ToString();//"ReplaceTitleString";
return ReplaceAction.Replace;
}
}
I hope this will help. In case of any ambiguity, please let me know.