Results 1 to 3 of 3

Thread: How can I?

  1. #1

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200

    How can I?

    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!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    u mean searching long text ?????

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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:
    1. Public Function Between(ByVal text As String, ByVal start As String, ByVal finish As String) As String
    2.         Dim sindex As Integer = (text.IndexOf(start) + start.Length)
    3.         Dim findex As Integer = text.IndexOf(finish)
    4.         Try
    5.             Return text.Substring(sindex, findex - sindex)
    6.         Catch ex As Exception
    7.             Return String.Empty
    8.         End Try
    9.     End Function
    10.  
    11.         'use it like this in a form or where ever
    12.         Dim str As String = "blah blah blah <title>You found me</title> more text here"
    13.         MsgBox(Between(str, "<title>", "</title>"))

    It could use some better exception handling though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width