Solved

ASP.NET/VB: Remove rubbish when splitting array from string

Posted on 2014-01-16
1
257 Views
Last Modified: 2014-01-16
In this example, the array contains rubbish:
yz[]=1&
yz[]=2&
yz[]=3&world

Open in new window

I want the array to only contains this:
1
2
3

Open in new window

<%@ Page Language="VB"%>
<%

Dim xyz As Array = "hello?xyz[]=1&xyz[]=2&xyz[]=3&world".split("xyz[]")

For index = 1 To xyz.GetUpperBound(0)
    HttpContext.Current.Response.Write(xyz(index))
    HttpContext.Current.Response.Write("<br>")
Next 

%>

Open in new window

0
Comment
Question by:hankknight
1 Comment
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 39785332
Instead of splitting on "xyz[]", split on "&".

This may work better (untested):
Dim x as String = "hello?xyz[]=1&xyz[]=2&xyz[]=3&world"

For Each element as String in x.split("&")
    If element.Contains("xyz[]") Then
        HttpContext.Current.Response.Write(element.split("=")(1) & "<br />")
    End If
Next

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help parsing JSON in my VB.Net application 4 44
Displaying a web form as a modal popup dialog box. 4 23
Message not shown 5 33
IIS Authorization for Web Service 2 22
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now