请检查以下代码..
Sub sampleregex()Dim regEx As New RegExp regEx.Pattern = "[\{\[][A-z0-9\s\.\,\:\;]*[\]\}]" regEx.Global = True Dim match As match Dim Content As Range Set Content = ActiveDocument.Content Dim matches As MatchCollection Set matches = regEx.Execute(ActiveDocument.Range) For Each match In matches Debug.Print vbTab & "Occurence #" & vbTab & match 'ActiveDocument.Range(match.FirstIndex, match.FirstIndex + match.Length).Select 'Selection.Text = "changed" Next match End Sub
我需要在文档中选择匹配的项目,如果在某些条件下需要修改,则会更改所选项目。我使用了注释行来选择文档中匹配的项目。但是,它无法选择。是否有任何替代方法可以逐个查找匹配项。
我已经尝试过通配符:VBA Regex unable to read the string 但是在找到引文后却没有阅读。 请帮助我!!