asp_databases thread: strings
Message #1 by jay48202@y... on Mon, 7 Oct 2002 15:11:48
|
|
Hi,
I have a string "a@x...,b@y...,c@z...,d@w...". I need two strings as
str1="a,b,c,d"
str2="x,y,z,w"
how to get the strings. The elements in the first string could be any
number. Wanna know the dynamic way.
Thanks,
Jay
Message #2 by "Peter Foti (PeterF)" <PeterF@S...> on Mon, 7 Oct 2002 10:33:28 -0400
|
|
This should work.
<%
Dim myString
myString = "a@x...,b@y...,c@z...,d@w..."
Dim arrElements
Dim str1
Dim str2
Dim tmpArr
arrElements = Split( myString, "," )
For i = 0 to UBound(arrElements)
tmpArr = Split( arrElements(i), "@" )
str1 = str1 & "," & tmpArr(0)
str2 = str2 & "," & tmpArr(1)
Next
' Remove extra leading comma
str1 = Mid( str1, 2 )
str2 = Mid( str2, 2 )
Response.Write("<div>" & str1 & "</div>")
Response.Write("<div>" & str2 & "</div>")
%>
Regards,
Pete
> -----Original Message-----
> From: jay48202@y... [mailto:jay48202@y...]
> Sent: Monday, October 07, 2002 3:12 PM
> To: ASP Databases
> Subject: [asp_databases] strings
>
>
> Hi,
>
> I have a string "a@x...,b@y...,c@z...,d@w...". I need two strings as
>
> str1="a,b,c,d"
> str2="x,y,z,w"
>
> how to get the strings. The elements in the first string could be any
> number. Wanna know the dynamic way.
>
> Thanks,
>
> Jay
>
|