how do i split a string, with two split request !?

if i have this text (maybe with some other separators)

tester;; test; test2; tester5;; test4;

how can i then split this string, so if two ;; then i get UPPER letters and if only one ; then just get the text as it is, and put the data into a response.write so i get this output:

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi, something like this should work.


mystring = "tester;; test; test2; tester5;; test4;"
arrSplit1 = Split(mystring, ";;")
For Each strBit1 In arrSplit1
	arrSplit2 = Split(strBit1, ";")
	For intBit2 = LBound(arrSplit2) To UBound(arrSplit2)
		If intBit2 = UBound(arrSplit2) Then
			WScript.Echo Trim(UCase(arrSplit2(intBit2)))
			WScript.Echo Trim(arrSplit2(intBit2))
		End If

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Randy DownsOWNERCommented:
Maybe this will help. You just need to change the delimiter

textdelimiter = ";"

Beginning of script Reading a delimited text file written by G.Ajaykumar<>--%>

<%@Import Namespace="System.IO"%>
<script language="vb" runat="server">
Sub page_load(Sender As Object,e As EventArgs)
Dim filetoread as string
dim filestream as StreamReader
filestream = File.Opentext(filetoread)
Dim readcontents as String
readcontents = fileStream.ReadToEnd()
Dim textdelimiter as String
textdelimiter = ","
Dim splitout = Split(readcontents, textdelimiter)
lblplaintext.text = readcontents & "<br>"
dim i as integer
for i=0 to Ubound(splitout)
lblsplittext.Text &= "<b>Split </b>" & i+1 & ") " & splitout(i)& "<br>"
End Sub
<asp:label align="center" ForeColor="Maroon" Font-Names="Arial" BackColor="LemonChiffon" BorderColor="#0000C0" runat="server" id="lbldisplay" Font-Name="Verdana" text="Reading a delimited text file using ASP.NET/VB.NET coded by G.Ajaykumar" /><br />
<br /><br /><b>Plain Output</b><br />
<asp:label runat="server" id="lblplaintext" Font-Name="Verdana" /><br />
<b>Split Output</b><br />

<asp:label runat="server" id="lblsplittext" Font-Name="Verdana" />
<%-- End of script--%
Bill PrewIT / Software Engineering ConsultantCommented:
Here's a small code snipit that might give you a starting place, I coded as a stand alone VBS just for some testing.

strInput = "tester;; test; test2; tester5;; test4;"

arrInput = Split(strInput, ";")
intMax = UBound(arrInput) - 1

i = 0
While i <= intMax
   n = 1
   If i < intMax Then
      If arrInput(i + 1) = "" Then
         arrInput(i) = UCase(arrInput(i))
         n = 2
      End If
   End If
   WScript.Echo Trim(arrInput(i))
   i = i + n

Open in new window

tjgrindstedAuthor Commented:
Hi all thx.

I used ur code, it works fine after edit a little in it, but thx.
The code is
    Sub input()
        Dim mystring As String = "tester;; test; test2; tester5;; test4;"
        Dim arrSplit1 As String() = Split(mystring, ";;")
        For Each strBit1 In arrSplit1
            Dim arrSplit2 As String() = Split(strBit1, ";")
            For intBit2 = LBound(arrSplit2) To UBound(arrSplit2)
                If intBit2 = UBound(arrSplit2) Then
                    Response.Write(Trim(UCase(arrSplit2(intBit2))) & "<br />")
                    Response.Write(Trim(arrSplit2(intBit2)) & "<br />")
                End If
    End Sub

Open in new window

tjgrindstedAuthor Commented:
need to edit a little in it, but after that it worked fine.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.