VBA Code(假设在 Excel 的活动工作表的 A1 单元格中存储着上述 Json 字符串):
Option Explicit
Sub ExtractJsonData()
Dim objRegExp As Object
Dim objMatch As Object
Dim objMatches As Object
Set objRegExp = CreateObject("VBScript.RegExp")
With objRegExp
.IgnoreCase = True
.Global = True
.Pattern = """issue"":""(\d+?)"",""opennum"":""(.*?)"""
If .Test([A1]) Then
Set objMatches = .Execute([A1])
For Each objMatch In objMatches
Debug.Print objMatch.SubMatches(0); objMatch.SubMatches(1)
Next
End If
End With
End Sub
运行结果:
表达式就是代码中的 Pattern 属性值