如何使用excel的VBA正则表达式截取字符串的iP

2025年03月21日 17:08
有2个网友回答
网友(1):

m = Cells(1, 1) '为字符所在单元格
a = InStr(m, ".")
For i = a - 1 To 1 Step -1
If IsNumeric(Mid(m, i, 1)) = False Then
c = i
Exit For
End If
Next
m = Right(m, Len(m) - c)
b = InStrRev(m, ".")
For i = b + 1 To Len(m)
If IsNumeric(Mid(m, i, 1)) = False Then
c = i
Exit For
End If
Next
If c = Len(m) Then
Else
m = Left(m, c - 1)
End If
MsgBox m

网友(2):

\d+\.\d+\.\d+\.\d+