?
Solved

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

Posted on 2014-01-16
1
Medium Priority
?
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 2000 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

764 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