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
Printable View
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
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.
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.
you can always use regular expressions
GameBit ... You would do this how? Can you provide an example that would work with greenba's data?Quote:
Originally Posted by GameBit
Attachment...