我在 VB6 用的 Regex 小模块
Felix Yan | 2010-07-16 | 192 views
我一直在用 VB6 写的各种需要正则的小程序里引入这个模块, 很简洁很好用:)
使用之前当然需要在 工程 -> 引用 里勾选 Microsoft VBScript Regular Expression 5.5
具体用法嘛…
1, StrReplace(正则替换):
MsgBox StrReplace("1d2e3f","\d","a")
将会输出
adaeaf
2, StrMatch(正则查找):
Dim mhs As MatchCollection Set mhs = StrMatch("1d2e3f","\d") If mhs.Count > 0 Then For i = 1 To mhs.Count MsgBox mhs(i).Value Next i End If
具体效果嘛…能猜到了吧? 猜不到的自己试试去… 其他用法请参见MSDN
下面附上模块源码:
Read the rest of this entry »



