问题
I started to create a code (in VB.NET) to extract information from texts;
The thing that I could not find in StackOverflow and search engines is an example of replacing/removing the text between "<" and ">"
Probably it is REPLACE
or REGEX
; I tried both, but could not figure it out;
Can I get some help....
Much appreciated...
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim SSSS = Replace(Label1.Text, "<td>", vbNewLine, 1, , CompareMethod.Text)
MessageBox.Show(SSSS)
End Sub
End Class
The above (in VB.NET) will split my text into line if I have <td>
; but I want to add the following:
My Text I am working on is:
test1<img alt='dddddd' src='https://mekdam.com'><div class='what'>test2</div><div class='code'>more</div>
I want to get test1 test2
from that in VB.NET
回答1:
Try Like this
Private Sub StrRep(ByVal xstr As String)
Dim xst As Integer = xch.IndexOf("<")
Dim xend As Integer = xch.IndexOf(">")
Dim xsub As String = xstr .Substring(xst, (xend - xst) + 1)
xstr = xstr .Replace(xsub, String.Empty)
If xstr .Contains("<") Then
Call StrRep(xstr )
Else
MsgBox(xstr )
End If
End Sub
来源:https://stackoverflow.com/questions/24566393/replace-remove-string-between-two-characters