Selection.WholeStory '全部选择
Dim Resault As String
Resault = Selection
Resault = Selection.Text '提取 字符串 与 带表格的特殊符号
MsgBox Resault
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
With regex
.Global = True
.Pattern = "\b\w*\b" '正则表达式 MsgBox .Replace(Resault, "")
End With
我想去掉Selection中含有的表格部分
表格在Selection中表示为1
D
2
B
使用"\b\w*\b"无法匹配出任何以开头的字符串 不知道为什么
顺便求能够完整匹配表格的字符串
VBA正则表达式String
Dim Resault As String
Resault = Selection
Resault = Selection.Text '提取 字符串 与 带表格的特殊符号
MsgBox Resault
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
With regex
.Global = True
.Pattern = "\b\w*\b" '正则表达式 MsgBox .Replace(Resault, "")
End With
我想去掉Selection中含有的表格部分
表格在Selection中表示为1
D
2
B
使用"\b\w*\b"无法匹配出任何以开头的字符串 不知道为什么
顺便求能够完整匹配表格的字符串
VBA正则表达式String
Sub test1()
Selection.WholeStory '全部选择
Dim Resault As String
Resault = Selection
Resault = Selection.Text '提取字符串与带图片的特殊符号
MsgBox Resault
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
With regex
.Global = True '返回"a#b#c#"
'.Global = False'返回"a#b2c3"
.Pattern = "\b\w*\b" '正则表达式
MsgBox .Replace(Resault, "")
End With
End SubSub test1()
Selection.WholeStory '全部选择
Dim Resault As String
Resault = Selection
Resault = Selection.Text '提取字符串与带图片的特殊符号
MsgBox Resault
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
With regex
.Global = True '返回"a#b#c#"
'.Global = False'返回"a#b2c3"
.Pattern = "\b\w*\b" '正则表达式 MsgBox .Replace(Resault, "")
End With
End Sub
与Microsoft VBScript Regular Expressions 1.0的引用了