请帮忙。我有一个代码。代码搜索 @"<(3)[-^~]([1-4])[-^~]([1-4])[-^~]([0-9]{1;3})?([0-9]{2})>" //(strings like 3-2-1-123-15 )
并将超链接放在上面。但想象一下,如果
3-2-1-123-15
数字之间有 NON-BREAKING HYPHEN。如果我将范围设置为文本(string s = rng.Text;
)(我需要它,因为我在超链接中使用相同的字符串: rngFound.Range.Hyperlinks.Add(rngFound.Range, hyperlink + rngFound.Text));
那么我将拥有:
32112315
情况。但是我怎么能有带“-”的字符串。我的意思是如何用“-”替换非中断连字符。我需要在word text中替换它吗?(不是很好)。如果我这样做了,我该如何使用函数来做到这一点:
Word.Selection FindAndReplace2(Word.Selection rngToSearch, object findText, object replaceWithText) //Find function
{
bool found = false;
//options
object matchCase = false;
object matchWholeWord = true;
object matchWildCards = true;
object matchSoundsLike = false;
object matchAllWordForms = false;
object forward = true;
object format = false;
object matchKashida = false;
object matchDiacritics = false;
object matchAlefHamza = false;
object matchControl = false;
object read_only = false;
object visible = true;
object replace = true;
object wrap = Word.WdFindWrap.wdFindStop; ;
//execute find and replace
found = rngToSearch.Find.Execute(ref findText, ref matchCase, ref matchWholeWord,
ref matchWildCards, ref matchSoundsLike, ref matchAllWordForms, ref forward, ref wrap, ref format, ref replaceWithText, ref replace,
ref matchKashida, ref matchDiacritics, ref matchAlefHamza, ref matchControl);
if (!found)
{
rngToSearch = null;
}
return rngToSearch;