您的位置:首页 > 编程语言 > VB

vb.net中的正则用法

2006-07-22 14:49 465 查看
Imports System.Text.RegularExpressions

Public Class frmMain
Inherits System.Windows.Forms.Form

Dim oWebClient As New System.Net.WebClient
Dim bSourceCode() As Byte

Function GetSourceCode(ByVal sUrl As String) As String
'取得网页的网址并取得文本代码
bSourceCode = oWebClient.DownloadData(sUrl)
GetSourceCode = System.Text.Encoding.Default.GetString(bSourceCode)
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim strTemp As String
strTemp = GetSourceCode("网页地址")

Dim objRegExp As Regex
Dim objMatch As Match
Dim objMatchs As MatchCollection
objMatchs = objRegExp.Matches(strTemp, "http:////([/w.]+//?)/S*")
For Each objMatch In objMatchs
Debug.WriteLine(objMatch.Value)
Next

End Sub

End Class
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: