Function TestRegExp(ByVal myString$, ByVal myPattern$, optional myMark$ = "gimt ",optional myrepostring $)
If myString = ""or myPattern = ""then
TestRegExp = " "
Debugging. Print "Data cannot be empty"
Exit function
If ... it will be over.
Create an object.
Dim objRegExp As RegExp
Dim object matching as a match
Dim column matching as a matching set.
Dim RetStr as a string
Set objRegExp = New RegExp
Conventional formula
objRegExp。 Mode = My Mode
IIf(InStr(myPattern," s ")& lt; & gt0,"",myPattern)
Is it case sensitive?
objRegExp。 ignore case = IIf(InStr(LCase $(my mark)," I ")& gt; 0, true or false)
Is it global?
objRegExp。 Global = IIf(InStr(LCase$(myMark)," g ")& gt; 0, true or false)
Do you want to pack?
objRegExp。 MultiLine = IIf(InStr(LCase $(my mark)," m ")& gt; 0, true or false)
If objRegExp. Then test (myString)
If InStr(myMark," r ")& gt; Then 0
Debugging. Print "replace"
RetStr = objRegExp。 Replace (my string, my string)
Debugging. Print IIF (retstr < & gt "","Replace result"&; Left(RetStr, 10), "No replaceable character found")
other
Debugging. Print "search"
Set colMatches = objRegExp。 Perform (myString)' perform a search.
The MsgBox column matches. count
For each objMatch in the Iterate Matches collection of colMatches.
RetStr = RetStr & ampobjMatch。 First index
RetStr = RetStr & ampobjMatch。 Value and value. vbCrLf
then
Debugging. Print IIF (retstr < & gt "","search results"&; Left(RetStr, 10), "No matching result found")
If ... it will be over.
other
RetStr = " "
Debugging. Print "No matching result found, please check whether the general formula is correct"
If ... it will be over.
TestRegExp = RetStr
End function