我正在尝试根据 1. 2. 年的经验来匹配各种职位的经验水平。该模式相当简单(例如:“BS/5”将是具有 5 年经验的理学学士学位。我也有遵循此方案但在同一字符串中具有多个学位和经验级别的条目(例如:“BS/ 5-MS/2") 被认为是等效的。我有一个基本函数可以匹配并找到子字符串模式,但即使我已将正则表达式的 .Global 属性设置为 true,它也不会返回多个匹配项对象。有什么想法吗?代码如下:
On Error Resume Next
ActiveWorkbook.VBProject.References.AddFromGuid "{3F4DACA7-160D-11D2-A8E9-00104B365C9F}", 5, 5
Dim theRegex As Object
Dim theString As String
Set theRegex = CreateObject("VBScript.RegExp")
With regex
.MultiLine = False
.Global = True
.IgnoreCase = False
End With
theRegex.Pattern = "([A-z][A-z][A-z]?/[0-9][0-9]?)"
theString = "MS/9-PhD/4"
Set MyMatches = theRegex.Execute(theString)
Debug.Print "SubMatches.Count: " & MyMatches.Item(0).SubMatches.Count
If MyMatches.Count <> 0 Then
With MyMatches
For myMatchCt = 0 To .Count - 1
Debug.Print "myMatchCt: " & myMatchCt
For subMtCt = 0 To .Item(subMtCt).SubMatches.Count - 1
Debug.Print "subMtCt: " & subMtCt
Debug.Print ("," & .Item(myMatchCt).SubMatches.Item(subMtCt))
Next
Next
End With
Else
Debug.Print "No Matches"
End If