Sep 19th, 2006, 08:37 PM
#1
Thread Starter
Lively Member
read string and extract
Hi,
I have the following string:
"<1>Company</1><a1>Name</a>"
What I need is to extract Company and Name only.
any ideas?
regards
Sep 19th, 2006, 09:09 PM
#2
Frenzied Member
Re: read string and extract
Are all strings you need to process in that exact format and sequence?
Find the position of "><" with InStr, use Left, Right or Mid to cut it into two strings and then remove the tags.
Sep 19th, 2006, 09:22 PM
#3
Member
Re: read string and extract
Yes, if the tags are exactly that way, then yes, he could use instr. But what if not?
I quickly typed this out ...
VB Code:
Dim RecordData As String
Dim FieldData() As String
Dim intA As Integer
Dim InsideHTMLTag As Boolean
ReDim FieldData(0)
RecordData = "<1>Company</1><a1>Name</a>"
InsideHTMLTag = False
For intA = 1 To Len(RecordData)
Select Case Mid(RecordData, intA, 1)
Case "<"
InsideHTMLTag = True
Case ">": InsideHTMLTag = False
If FieldData(UBound(FieldData)) <> "" And intA < Len(RecordData) Then
ReDim Preserve FieldData(UBound(FieldData) + 1)
End If
Case Else
If InsideHTMLTag = False Then
FieldData(UBound(FieldData)) = FieldData(UBound(FieldData)) & Mid(RecordData, intA, 1)
End If
End Select
Next intA
It works on your given example, using the < and > symbols as markers to determine whether it's in or out of a tag. Then it puts the data into the FieldData array. Pull the data out of the array starting at 0. It should work to split any data that is outside of HTML tags. Let me know how it works.
Sep 20th, 2006, 03:18 AM
#4
Addicted Member
Re: read string and extract
you can always use regular expressions
P.S. Sorry for my poor English...
Sep 20th, 2006, 08:14 AM
#5
Member
Re: read string and extract
Originally Posted by
GameBit
you can always use regular expressions
GameBit ... You would do this how? Can you provide an example that would work with greenba's data?
Sep 21st, 2006, 01:00 AM
#6
Addicted Member
Re: read string and extract
Attached Files
P.S. Sorry for my poor English...
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