VB通过正则表达式定位字符串 |
|
www.nanhushi.com 佚名 不详 |
VB 通过正则表达式定位字符串的实现方法如下: [工程]-[引用] \"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
|
|
|
文章录入:杜斌 责任编辑:杜斌 |
|
上一篇文章: vb的RSA公钥和私钥 下一篇文章: 辅导:VB颜色函数 |
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
|