VBA. How to find position of first digit in string

前端 未结 6 1231
陌清茗
陌清茗 2020-12-31 08:47

I have string \"ololo123\". I need get position of first digit - 1. How to set mask of search ?

6条回答
  •  渐次进展
    2020-12-31 09:05

    Not sure on your environment, but this worked in Excel 2010

    'Added reference for Microsoft VBScript Regular Expressions 5.5
    
    Const myString As String = "ololo123"
    Dim regex As New RegExp
    Dim regmatch As MatchCollection
    
    regex.Pattern = "\d"
    Set regmatch = regex.Execute(myString)
    MsgBox (regmatch.Item(0).FirstIndex)   ' Outputs 5
    

提交回复
热议问题