Matching function of a regular expression in excel?

天涯浪子 提交于 2019-12-06 11:50:14

The following function will do what you need. It will return either 0 (zero) if string doesn't match or 1 (one) if the string matches to pattern.

Function MatchISIN(ISIN As String)

    Dim regEx As Object
    Set regEx = CreateObject("vbscript.regexp")

    regEx.Pattern = "^[a-zA-Z]{2}[0-9]{10}$"
    regEx.IgnoreCase = True
    regEx.Global = True

    Dim Matches As Object
    Set Matches = regEx.Execute(ISIN)

    MatchISIN = Matches.Count

End Function

You could use the built-in Like method;

if "DE0006231009" like "[A-Za-z][A-Za-z]##########" then ...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!