Results 1 to 4 of 4

Thread: String Extraction

  1. #1
    Guest
    I'm trying to extract a string out of a line in a file. For example, in the line of a text file I have

    <TITLE>string to extract here</TITLE>

    In which case I need to extract the string. The string will be different lengths in different files. Anyone know how to go about this?

  2. #2
    New Member
    Join Date
    Aug 2000
    Posts
    9
    I have done this using the Split function. If posible find a way to dilimit, "<Title>", the return is a string array.


  3. #3
    Guest
    Try this:
    Code:
    Function ExtractString(sSearch As String, sBracket1 As String, sBracket2 As String) As String
        Dim iBracket1 As Long, iBracket2 As Long
        
        iBracket1 = InStr(1, UCase(sSearch), sBracket1)
        iBracket2 = InStr(iBracket1, UCase(sSearch), sBracket2)
        ExtractString = Mid(sSearch, iBracket1 + Len(sBracket1), iBracket2 - Len(sBracket2))
    End Function
    Usage:

    MsgBox ExtractString(Text1, "<TITLE>", "</TITLE>")




  4. #4
    Guest
    Thanks. Thats worked. But it seems to work only on short HTML tags. For example, when I try something like this:

    myNewFile.writeline ExtractString(strFileRead, "<TD WIDTH=""60"" ALIGN=""RIGHT""><B><U>", "</U></B></TD>")

    It prints the string I'm looking for and the trailing HTML tags. Am I doing something wrong here?

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