我想同时匹配 ac, abc, abbc, abbbc ....
ab@c不能匹配0个b
ab{0,}c似乎不合法
有办法查找一次,匹配这样的字符串吗?
------解决方案--------------------------------------------------------
又写了一段不使用VBScript的,直接使用Word VBA内置功能的,楼主试一下:
- VB code
Sub 查找零个以上指定字符() Dim i As Integer Dim strfind As String Dim IsB As Boolean Selection.HomeKey unit:=wdStory With Selection.Find .Text = "a*c" .MatchWildcards = True .Execute Forward:=True Do While .Found strfind = Mid(Selection.Text, 2, Len(Selection.Text) - 2) IsB = True For i = 1 To Len(strfind) If strfind = "" Then MsgBox Selection.Text: Exit For If Mid(strfind, i, 1) <> "b" Then IsB = False: Exit For Next i If IsB Then MsgBox Selection.Text Selection.EndKey unit:=wdLine .Execute Loop End WithEnd Sub