
VB6 如何取正则表达式的值?
我知道如何使用表达式,匹配IP格式。。但是怎么取值。。例如:模块:PublicFunctionisValidIpAddress(strIpAddressAsString)...
我知道如何使用表达式,匹配IP格式。。但是怎么取值。。
例如:
模块:
Public Function isValidIpAddress(strIpAddress As String) As Boolean
On Error Resume Next
Dim reg As New RegExp
reg.IgnoreCase = True
reg.Global = True
reg.MultiLine = True
reg.Pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
isValidIpAddress = reg.Test(strIpAddress)
If isValidIpAddress = True Then
Dim strArr() As String
strArr = Split(strIpAddress, ".")
For i = 0 To UBound(strArr)
isValidIpAddress = isValidIpAddress And isValidIpNumber(strArr(i))
Next i
End If
End Function
条件:一个text,一个command
text1.text="textbox value=244.85.197.14z.zcls="z-textbox" z.type="zul.vd.Txbox"""
单击command1
If isValidIpAddress(Text1.Text) = True Then
MsgBox "有效IP :" '正则表达式返回值
Else
MsgBox "无效IP"
End If
End Sub
其中上面的 正则表达式返回true,但是如何取 text1.text 里面的 244.85.197.14,这个值呢? 展开
例如:
模块:
Public Function isValidIpAddress(strIpAddress As String) As Boolean
On Error Resume Next
Dim reg As New RegExp
reg.IgnoreCase = True
reg.Global = True
reg.MultiLine = True
reg.Pattern = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
isValidIpAddress = reg.Test(strIpAddress)
If isValidIpAddress = True Then
Dim strArr() As String
strArr = Split(strIpAddress, ".")
For i = 0 To UBound(strArr)
isValidIpAddress = isValidIpAddress And isValidIpNumber(strArr(i))
Next i
End If
End Function
条件:一个text,一个command
text1.text="textbox value=244.85.197.14z.zcls="z-textbox" z.type="zul.vd.Txbox"""
单击command1
If isValidIpAddress(Text1.Text) = True Then
MsgBox "有效IP :" '正则表达式返回值
Else
MsgBox "无效IP"
End If
End Sub
其中上面的 正则表达式返回true,但是如何取 text1.text 里面的 244.85.197.14,这个值呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询