|
-
Aug 16th, 2000, 03:30 PM
#1
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?
-
Aug 16th, 2000, 03:45 PM
#2
New Member
I have done this using the Split function. If posible find a way to dilimit, "<Title>", the return is a string array.
-
Aug 16th, 2000, 03:47 PM
#3
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>")
-
Aug 17th, 2000, 11:18 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|