Solved

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

Posted on 2014-01-16
1
259 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C#.NET MSVS 2010 is there some things not allowed in Background Worker DoWork? 27 37
Get month and date in a format 4 35
Groupbox Control ? 2 20
Why use this lambda? 12 41
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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