How can i search through a long string and find what is between say...<title>what is here</title> between the title tags or between <br>what is here and <br> how can i search for things like that in .Net....?????
THanks!
Printable View
How can i search through a long string and find what is between say...<title>what is here</title> between the title tags or between <br>what is here and <br> how can i search for things like that in .Net....?????
THanks!
u mean searching long text ?????
If they are also in tags like <b></b> you may be able to open it as xml in a dataset or xmlnode. If not then you can use this:
VB Code:
Public Function Between(ByVal text As String, ByVal start As String, ByVal finish As String) As String Dim sindex As Integer = (text.IndexOf(start) + start.Length) Dim findex As Integer = text.IndexOf(finish) Try Return text.Substring(sindex, findex - sindex) Catch ex As Exception Return String.Empty End Try End Function 'use it like this in a form or where ever Dim str As String = "blah blah blah <title>You found me</title> more text here" MsgBox(Between(str, "<title>", "</title>"))
It could use some better exception handling though.