Sub Regexp_test(Sht As String, str As String)
On Error Resume Next
Dim regx As Object
Dim arr, brr, mh
Set regx = CreateObject("vbscript.regexp")
With regx
.Global = True
'此处填入正则表达式
.Pattern = ""
End With
With Sheets(Sht)
arr = .Range("C2:C" & .[A65536].End(xlUp).Row)
ReDim brr(1 To UBound(arr), 1 To 1)
For i = 1 To UBound(arr)
Set mh = regx.Execute(arr(i, 1))
If mh(0).submatches(1) Like "*-*月*" Then
brr(i, 1) = VBA.Mid(mh(0).submatches(1), (VBA.InStr(mh(0).submatches(1), "月") + 1), (VBA.InStr(mh(0).submatches(1), "_") - 1))
ElseIf mh(0).submatches(1) Like "*_*" Then
brr(i, 1) = VBA.Left(mh(0).submatches(1), VBA.InStr(mh(0).submatches(1), "_") - 1)
Else
brr(i, 1) = mh(0).submatches(1)
End If
Next i
End With
On Error GoTo 0
End Sub