Copy Code code as follows:
Dim Strok,strno
Strok = "12312321$12312312312$12312321$"
Strno = "12312321$12312312312$12312321$SDFSD"
Function regexptest (PATRN, STRNG)
Dim regEx, match, matches ' set variable.
Set regEx = New RegExp ' establishes a canonical expression.
Regex.pattern = Patrn ' Set mode.
Regex.ignorecase = True ' Sets whether the case of letters is case-sensitive.
Regex.global = False ' sets the whole nature.
Set matches= regex.execute (STRNG) ' performs a search.
For the match in matches ' duplicate matching collection
Retstr=retstr & "Match found at position"
retstr=retstr&match.firstindex& ". Match Value is ' "
retstr=retstr&match.value& "'." &vbcrlf
Next
IF not IsEmpty (matches) and matches (0). Value = Strng Then
Regexptest = True
Else
Regexptest = False
End IF
End Function
MsgBox (Regexptest ("[\d+\$]+", Strok))