查找并替换word文档中的模式 [英] Find and replace a pattern in word document

查看:118
本文介绍了查找并替换word文档中的模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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.

提前致谢。

推荐答案

我想在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.

提前致谢。


这篇关于查找并替换word文档中的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆