vb에서 regex로 찾은 걸 string으로 가져오는 법이 궁금합니다.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim response As System.Net.HttpWebResponse = request.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim rssourcecode As String = sr.ReadToEnd
/홈페이지에 들어가서 읽어오고
Dim r As New System.Text.RegularExpressions.Regex("
http://.*")
Dim matches As MatchCollection = r.Matches(rssourcecode)
'매치하고
For Each itemcode As Match In matches
ListBox1.Items.Add(itemcode.Value.Split("""").GetValue(5))
' ""로 split해서 5번 값을 가져와서 listbox에 표시
Next
End Sub
End Class
이렇게하면 regex로 찾은 값을 전부 listbox로 가져오는 건 알겠습니다.
그런데 리스트박스를 쓰지않고 regex로 찾은 값 중에서 n번째 값만 string으로 복사해오는 방법을 모르겠습니다.
에를들어서
http://.*로 찾은 값 중에서 첫번째 것만 가져오고 싶은 경우 어떻게 하나요?
도와주세요.