Hello,
I am working on find and replace with Aspose.Words and used IReplacingCallback to style of found keyword as strikedout and replaced word as underline.
for this I have used SplitRun mentioned. Here the issue is SplitRun is not splitting into sub runs.
for example in the run.text = “this agreement (“AGREEMENT”) is for” will split only first occupancy thus only replacing the first find keyword (“agreement”) with no case match.
How can I do subruns to find and replace all the occurrence in 1 sentence?
here is the split run code.
private static Run SplitRun(Run run, int position, string replacingWord)
{
Run afterRun = (Run)run.Clone(true);
if (run.Text.Length > position && run.ParentNode != null)
{
afterRun.Text = run.Text.Substring(position);
run.Text = run.Text.Substring(0, position);
run.ParentNode.InsertAfter(afterRun, run);
}
return afterRun;
}