![]() ![]() |
|
VB通过正则表达式定位字符串 | |
作者:佚名 文章来源:不详 点击数 更新时间:2008/10/22 21:37:45 文章录入:杜斌 责任编辑:杜斌 | |
|
|
[工程]-[引用] \"Microsoft VBScript Regular Expressions\" ’本例是要定位字符串s中数字出现的位置 Private Sub Command1_Click() Dim re As RegExp, s As String, Matchs s = \"http://blog.sina.com.cn/juyonghong/123456.html\" Set re = New RegExp re.Pattern = \"\\d+\" ’数字序列 If re.Test(s) Then ’测试是否存在 Set Matchs = re.Execute(s) Print Matchs(0).FirstIndex ’显示位置 End If End Sub |
|
![]() ![]() |