473,666 Members | 2,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

split() question

KC
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't know
how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken
Nov 20 '05 #1
5 1569
"KC" <yo*@dontneed.t his> skrev i en meddelelse
news:uI******** *****@TK2MSFTNG P11.phx.gbl...
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't know how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken


You have to do like this, atleast I don't know any other way

dim str as string = "234 23 42 234 234 234"
str = str.split(" ")
dim moreSpaces as integer = str.indexof(" ")
while morespaces <> -1
str = str.split(" ")
moreSpaces = str.indexof(" ")
end while
Nov 20 '05 #2
Use Regular Expressions.

"Richard" <s@b.k> wrote in message
news:ea******** *****@TK2MSFTNG P12.phx.gbl...
"KC" <yo*@dontneed.t his> skrev i en meddelelse
news:uI******** *****@TK2MSFTNG P11.phx.gbl...
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't

know
how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken


You have to do like this, atleast I don't know any other way

dim str as string = "234 23 42 234 234 234"
str = str.split(" ")
dim moreSpaces as integer = str.indexof(" ")
while morespaces <> -1
str = str.split(" ")
moreSpaces = str.indexof(" ")
end while

Nov 20 '05 #3
> dim str as string = "234 23 42 234 234 234"
str = str.split(" ")
dim moreSpaces as integer = str.indexof(" ")
while morespaces <> -1
str = str.split(" ")
moreSpaces = str.indexof(" ")
end while


LOL
My bad I thought i was another operation,
It will work with split, but there might be some empty strings in the array
you are getting
Nov 20 '05 #4
My bad, it will work
Nov 20 '05 #5
Ken,
As Juan suggested, you can use RegEx.Split...

There are three Split functions in .NET:

Use Microsoft.Visua lBasic.Strings. Split if you need to split a string based
on a specific word (string). It is the Split function from VB6.

Use System.String.S plit if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter.

Use System.Text.Reg ularExpressions .RegEx.Split to split based
on matching patterns.

Hope this helps
Jay
"KC" <yo*@dontneed.t his> wrote in message
news:uI******** *****@TK2MSFTNG P11.phx.gbl...
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't know how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken

Nov 20 '05 #6

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

Similar topics

3
415
by: alexk | last post by:
I've a simple question. Why the following: words = "123#@$#$@^% wordB#@$".split('~`!@#$%^&*()_+-={},./') doesn't work? The length of the result vector is 1. I'm using ActivePython 2.4 Alex
2
12822
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces, the employer code in column 23 for 29 spaces and employer description in column 53 for 30 spaces. I have tried modifying an existing file with no real success. I haven't found anything that specifically answers my question. Any guidance would be...
3
4418
by: rxl124 | last post by:
Hi, room Beginner of learning perl here!! I have question to all, I have below file name datebook.master which contains only 2 lines Mike wolf:12/3/44:144 park ave, paramus: 44000 Sarah kim: 3/2/67:255 lomel ave, fort lee: 33000 Now, I am testing out below scripts and working fine.
6
6373
by: Senthil | last post by:
Code ---------------------- string Line = "\"A\",\"B\",\"C\",\"D\""; string Line2 = Line.Replace("\",\"","\"\",\"\""); string CSVColumns = Line2.Split("\",\"".ToCharArray());
3
2097
by: John Salerno | last post by:
This is an example in the book I'm reading: string fullName = " Edward C Koop "; fullName = fullName.Trim(); string names = fullName.Split(' '); string firstName = names; // Edward Two questions about this: 1. Why do you use single quotes with Split() instead of double? Is this
4
6037
by: Michele Petrazzo | last post by:
Hello ng, I don't understand why split (string split) doesn't work with the same method if I can't pass values or if I pass a whitespace value: >>> "".split() >>> "".split(" ") But into the doc I see:
7
1292
by: Matthias Winterland | last post by:
Hi, I have a simple question. When I read in a string like: a='1,2,3,4,5 6 7,3,4', can I get the list l= with a single split-call? Thx, Matthias
9
1986
by: dtex23 | last post by:
Good afternoon all, Question about list assignment in perl... Given a piece of code that looks kinda like this for parsing some '|' delimited input text lines : ($var1, $var2, $var3) = split(/\|/, $listline); Here's the hard part: There are differing programs that read from the same conf file that take data stream and split it, but at some point in the future I may need to expand the variables split to. I would like to basically put...
1
2429
by: John | last post by:
Hi I have written a Split function which in turn calls the standard string split function. Code is below; Function Split1(ByVal Expression As String, Optional ByVal Delimiter As String = " ", Optional ByVal Limit As Integer = -1, Optional ByVal Compare As CompareMethod = CompareMethod.Binary, Optional ByVal MaxLength As Integer = 0) As String()
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8866
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
8781
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
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6191
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
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
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...
1
2769
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
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.