Hi Thomas,
Thanks for your inquiry. Please note that the matched text can be in one or multiple Run nodes. In your case, we suggest you please use following modified code example to get the desired output. Hope this helps you.
Sub Main()
Dim filename As String = ".\anfangstext.doc"
Dim doc As New Aspose.Words.Document(filename)
doc.JoinRunsWithSameFormatting()
FillWordFields(doc)
doc.Save(".\AfterSearch.doc")
Console.WriteLine("Search/Replace finished")
Console.WriteLine("Output saved in .\AfterSearch.doc")
Console.ReadKey()
End Sub
Private Sub FillWordFields(doc As Aspose.Words.Document)
Dim options As New Replacing.FindReplaceOptions
options.ReplacingCallback = New MyReplaceEvaluator
AddHandler CType(options.ReplacingCallback, MyReplaceEvaluator).FillReplace, AddressOf DoFillReplace
doc.Range.Replace(New Text.RegularExpressions.Regex("(?<=@)(.*?)(?=@)"), "", options)
End Sub
Private Sub DoFillReplace(Textrun As Run, Formfield As String)
Dim newvalue As String = "Newvalue:" + Textrun.Text.Replace("@", "")
Textrun.Font.Underline = Underline.None
Textrun.Text = newvalue
End Sub