473,769 Members | 8,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

remove an element from an array

I'm trying to parse a sentence and want to remove selected words from the
middle.

Consider:

dim a() as object = split(mySentenc e)

for each w in a()
select case w
case w.startswith("X ")
'code to remove this specific word from the array
end select
next

result = join(a)

Can't find a way to remove the word. Any help out there?

I'm now looking at arrayList, which might have the methods I need, but
haven't figured out how to do the split trick.

Jeremy
Nov 21 '05 #1
3 2121
I would first use replace to get rid of any double spaces then use split to
split the sentence up into an array of words based as a space as the
delimiter.

"Jeremy" wrote:
I'm trying to parse a sentence and want to remove selected words from the
middle.

Consider:

dim a() as object = split(mySentenc e)

for each w in a()
select case w
case w.startswith("X ")
'code to remove this specific word from the array
end select
next

result = join(a)

Can't find a way to remove the word. Any help out there?

I'm now looking at arrayList, which might have the methods I need, but
haven't figured out how to do the split trick.

Jeremy

Nov 21 '05 #2
"Jeremy" <je****@ninprod ata.com> schrieb:
I'm trying to parse a sentence and want to remove selected words from the
middle.

Consider:

dim a() as object = split(mySentenc e)

for each w in a()
select case w
case w.startswith("X ")
'code to remove this specific word from the array
end select
next

result = join(a)

Can't find a way to remove the word. Any help out there?


\\\
Dim al As New ArrayList()
al.InsertRange( 0, Split("Hello World Test", " "))
For Each Item As String In al
MsgBox(Item)
Next Item
///

- or -

\\\
Imports System.Collecti ons.Specialized
..
..
..
Dim s As New StringCollectio n()
s.AddRange(Spli t("Hello World Test", " "))
....
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Herfried, perfect. Thanks.

Jeremy

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ON******** *****@TK2MSFTNG P12.phx.gbl...
"Jeremy" <je****@ninprod ata.com> schrieb:
I'm trying to parse a sentence and want to remove selected words from the
middle.

Consider:

dim a() as object = split(mySentenc e)

for each w in a()
select case w
case w.startswith("X ")
'code to remove this specific word from the array
end select
next

result = join(a)

Can't find a way to remove the word. Any help out there?


\\\
Dim al As New ArrayList()
al.InsertRange( 0, Split("Hello World Test", " "))
For Each Item As String In al
MsgBox(Item)
Next Item
///

- or -

\\\
Imports System.Collecti ons.Specialized
.
.
.
Dim s As New StringCollectio n()
s.AddRange(Spli t("Hello World Test", " "))
...
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
55571
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are also removed) So far I have (val is value, ar is array, returns new array):
6
1785
by: Rimuen | last post by:
Have a string contains numbers from database. But there is similar numbers want to remove Example: 1,3,6,6,6,12,13,14,15,15,15,15 Want to remove the similar numbers so it would be like: 1,3,6,12,13,14,15 Any help ??
11
2746
by: koperenkogel | last post by:
Dear cpp-ians, I am working with a vector of structures. vector <meta_segment> meta_segm (2421500); and the structure look like: struct meta_segment { float id; float num;
7
6483
by: Derek Basch | last post by:
I can remove objects from an array by doing this: for (i in oCache){ if (i == "test"){ delete oCache; }; }; However, the array's length property is unaffected.
3
3810
by: Don | last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods. The "Add" method is working great. However I don't understand why the "Remove" method isn't working. It neither removes the item from the arraylist nor from the combobox like it's supposed to do. A couple of notes: cbx is the name of the combobox within my usercontrol, file is the name of the arraylist within my usercontrol. To try...
4
9830
by: eksamor | last post by:
I have a simple linked list: struct element { struct element *next; int start; }; struct list { struct element *head;
14
3048
by: oLgAa25 | last post by:
Hello all, I am back I have this question everything compiles fine, but I just need to check for an index that is more than the array size. Although it says out of bound, but it is still deleting the last element. Can someone help please Thank you all Olga I just wanted to test my function,so don't bother with main, and print
11
4511
by: Richard Maher | last post by:
Hi, I have read many of the copius entries on the subject of IE performance (or the lack thereof) when populating Select Lists. I don't mind the insert performance so much, (I get 100x120byte rows inserted/sec up to 500, and 100rows/6secs up to 3000, which isn't great but then the Row Count is clicking away for the user to see and they can hit the "cancel" button at anytime, so overall I'm happy), what really disappoints me is the...
3
5610
by: Barkingmadscot | last post by:
I am stuck, i can workout how to remove lines from an array I have loading a text file (a Log), I know which lines a need, but the logs can be upto 30K sometimes bigger. I found trying to delete the lines from the log file before loading in the array took ages, i thought i would be alot quicker to put in an array and remove the unwanted lines. Dim text As Array Dim lines As New List(Of String)
6
5502
by: tedpottel | last post by:
Help How can I remove an item from an array, Example Array=3, array=6 array=7 array=9 Is there a way to remove a item, say index 1, so the array would now be Array=3 array=7 array=9 ?????
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.