且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

查找并替换word文档中的模式

更新时间:2023-02-23 08:13:58

我想在word中找到一个模式并用VB.NET替换为其他文本

I want to find a pattern in word and replace it with other text with VB.NET

我使用以下内容代码也是如此:

I am using the following code to do the same :

        Dim range As Range = doc.Range



        Dim reg As New Regex(" ^ \s +")



        Dim rangeText As String = range.Text



        range.Text = reg.Replace(rangeText," bbbbb")

        Dim range As Range = doc.Range

        Dim reg As New Regex("^\s+")

        Dim rangeText As String = range.Text

        range.Text = reg.Replace(rangeText, "bbbbb")

但是如果我的内容包含"HYPERLINKS",它也会删除它。我知道还有其他的方式吗我也可以这样做。

But if my content contains "HYPERLINKS", it removes that also.Can i know is there any other way that i can do the same.

提前致谢。