VB 正则提取内容~~紧急求助!!!

SungCen 2009-03-20 02:45:38
文本格式这样的

<ul class="members">
<li><a href="http://wpa.qq.com/msgrd?V=1&Uin=992992&Site=群空间&Menu=yes" target="_blank" title=" 相 信"><img src="http://qun.qq.com/cgi/svr/face/getface?type=1&uin=992992" width="20" height="20" align="absmiddle" class="no" />
相 信 </a>
</li>
<li><a href="http://wpa.qq.com/msgrd?V=1&Uin=342190514&Site=群空间&Menu=yes" target="_blank" title="振东方"><img src="http://qun.qq.com/cgi/svr/face/getface?type=1&uin=342190514" width="20" height="20" align="absmiddle" class="no" />
振东方 </a>
</li>
</ul>


我想写个VB小程序怎么能够把内容中QQ号提取,并存放到一个文件里面啊?

请高手的帮下偶~~急用~~
...全文
160 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
a271878991 2010-03-09
  • 打赏
  • 举报
回复
友情~~~~帮顶~~~
ningyong58 2009-03-22
  • 打赏
  • 举报
回复
关注四则运算的帖子。
SYSSZ 2009-03-21
  • 打赏
  • 举报
回复
引用Microsoft VBScript Regular Expressions 5.5.
'两文本框设为多行显示
'将你的文本粘贴到Text1
Private Sub Command1_Click()
Dim re As RegExp
Dim mh As Match
Dim mhs As MatchCollection
Dim inpStr As String
inpStr = Text1.Text
Set re = New RegExp
re.Pattern = "\d{9}|\d{6}"
re.IgnoreCase = True
re.Global = 2
Set mhs = re.Execute(inpStr)

For Each Match In mhs
S = S & Match.Value & vbCrLf
Next
Text2.Text = S
End Sub
dlschan 2009-03-21
  • 打赏
  • 举报
回复
mark
lili830209 2009-03-21
  • 打赏
  • 举报
回复
mark
sonic_andy 2009-03-21
  • 打赏
  • 举报
回复
以上内容存为vbs,将input.txt修改为实际的文件名,然后双击运行即可.
sonic_andy 2009-03-21
  • 打赏
  • 举报
回复
set fso = createobject("scripting.filesystemobject")
set stream = fso.opentextfile("input.txt",1)
content = stream.readall
call stream.close

set reg = new regexp
reg.global = true
reg.pattern = "uin=(\d+)"
set matches = reg.execute(content)

for each match in matches
result = result & match.submatches(0) & vbcrlf
next

set stream = fso.opentextfile("output.txt",2,true)
call stream.write(result)
call stream.close

verywzm 2009-03-21
  • 打赏
  • 举报
回复
帮顶
zhufenghappy 2009-03-20
  • 打赏
  • 举报
回复
你在窗体加一个,Command1,两个文本框Text1、Text2,把你要提取的文本拷贝到Text1,点Command1,就可以看到你要的结果在Text2里(前提是你的格式就是你说的那样,如果出现和代码中判断的字符不符的可以修改)
Private Sub Command1_Click()
Dim Arr() As String
Dim i As Integer
Dim iStart As Long, iEnd As Long
Text2.Text = ""
Arr = Split(Text1.Text, "</li>")
For i = 0 To UBound(Arr) - 1
iStart = InStr(Arr(i), "V=1&Uin=") + 8
iEnd = InStr(Arr(i), "&Site=")
Debug.Print Mid(Arr(i), iStart, (iEnd - iStart))
Text2.Text = Text2.Text & ", " & Mid(Arr(i), iStart, (iEnd - iStart))
Text2.Text = Mid(Text2.Text, 2)
Next
End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧