Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Clone Visual studio 2013 solution 5 16
Asp.net mvc entity issue 6 20
Asp.net mvc 5 5 23
Asp.net mvc foreach 3 15
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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