I use regular expressions to search for plain text returned by the following property:
namespace Microsoft.Office.Interop.Word
{
public class Range
{
...
public string Text { get; set; }
...
}
}
Based on the matches, I want to make changes to the formatted text that matches the plain text. The problem is that the character indices in the property .Textdo not match the properties .Startand the .Endobject Range. Does anyone know of any way to match these indexes?
(I can't use Word's lookup lookup capabilities (as a replacement for .NET regular expressions) because they are not powerful enough for the patterns I'm looking for (not greedy operators, etc.))
I can move the correct number of characters, starting with Document.Range().Collapse(WdCollapseStart), and then range.MoveStart(WdUnitChar, match.Index), since moving through the characters corresponds to the formatted position of the text with matches in plain text.
Now my problem is that in the formatted text I always have 4 characters ... so maybe this has something to do with other ranges of plots? I'm not sure...
source
share