vb.net中的正则用法
2006-07-22 14:49
519 查看
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
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
相关文章推荐
- .net正则表达式 用法(一)
- VB.net一维数组用法
- VB.NET中的List用法
- 记录下C#/VB.NET中转义字符的用法
- VB.Net常用的正则表达式(实例)
- [VB.NET]谁能帮我用验证国内电话号码的正则表达式写一个验证程序啊?
- 关于VB.NET记录定义Type用法介绍
- VB.NET 通常用法使用笔记
- vb.net正则表达式快速入门(3)完
- asp.net中RegularExpressionValidator控件中正则表达式用法
- vb.net 正则表达式
- VB.Net Timer 控件的用法
- VB.Net正则表达式大全格式示例
- VB.NET中的List用法
- vb.net正则表达式快速入门(1)
- VB.NET Mid函数用法
- .net正则表达式 用法(小结)
- VB.NET利用正则表达式巧妙限制字符输入
- vb.net的using用法
- vb.net 2008 dataTable Sort()函数和Select()函数用法实例