Reputation: 124
Hello I'm trying to get a mass type of href into a listbox. Anyone know what's the regex match to get only that thing after href?
Here is a line from multiple ones which I'm trying to optain:
<a class="streamItemsAge" data-hint="January 13, 2016 12:15:31 GMT" href="/Game/player/19928271">yesterday</a>
Here is my code:
Dim pp As String = textbox1.text
Dim strRegex As String = "GMT"" <?href\s*=\s*[""'].+?[""'][^>]*?"
Dim myRegex As New Regex(strRegex, RegexOptions.None)
For Each myMatch As Match In myRegex.Matches(pp)
If myMatch.Success Then
ListBox1.Items.Add(myMatch)
End If
Next
Note: data-hint value will be different for each href, so I'm really confused. Please help me.
This will be the output: /Game/player/19928271
Upvotes: 0
Views: 77
Reputation: 139
Dim pp As String = textbox1.text
Dim strRegex As String = "data-hint.+href=""([^""]+)"""
Dim myRegex As New Regex(strRegex, RegexOptions.None)
For Each myMatch As Match In myRegex.Matches(pp)
If myMatch.Success Then
ListBox1.Items.Add(myMatch.Groups(1).Value)
End If
Next
Just adjusted Filepe's answer and stuck it in your code. Should do what you want.
Upvotes: 1