473,486 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Split a string into an array on space OR carriage return

Greetings,

Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?

Thanks,

-Dave
Nov 21 '05 #1
8 14177
Try.... String.Split() // the one with the array param if you want to split
on space OR CR

- José

"Dave" <no****@yahoo.com> a écrit dans le message de news:
uh**************@TK2MSFTNGP11.phx.gbl...
Greetings,

Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?

Thanks,

-Dave

Nov 21 '05 #2
Try.... String.Split() // the one with the array param if you want to split
on space OR CR

- José

"Dave" <no****@yahoo.com> a écrit dans le message de news:
uh**************@TK2MSFTNGP11.phx.gbl...
Greetings,

Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?

Thanks,

-Dave

Nov 21 '05 #3
Direct form MSDN Help on String.Split

Imports System
Imports Microsoft.VisualBasic
_

Public Class StringSplit2

Public Shared Sub Main()

Dim delimStr As String = " ,.:"
Dim delimiter As Char() = delimStr.ToCharArray()
Dim words As String = "one two,three:four."
Dim split As String() = Nothing

Console.WriteLine("The delimiters are -{0}-", delimStr)
Dim x As Integer
For x = 1 To 5
split = words.Split(delimiter, x)
Console.WriteLine(ControlChars.Cr + "count = {0,2} ..............",
x)
Dim s As String
For Each s In split
Console.WriteLine("-{0}-", s)
Next s
Next x
End Sub 'Main
End Class 'StringSplit2

Hope it helps
Chris
"Dave" <no****@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
Greetings,

Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?

Thanks,

-Dave

Nov 21 '05 #4
Direct form MSDN Help on String.Split

Imports System
Imports Microsoft.VisualBasic
_

Public Class StringSplit2

Public Shared Sub Main()

Dim delimStr As String = " ,.:"
Dim delimiter As Char() = delimStr.ToCharArray()
Dim words As String = "one two,three:four."
Dim split As String() = Nothing

Console.WriteLine("The delimiters are -{0}-", delimStr)
Dim x As Integer
For x = 1 To 5
split = words.Split(delimiter, x)
Console.WriteLine(ControlChars.Cr + "count = {0,2} ..............",
x)
Dim s As String
For Each s In split
Console.WriteLine("-{0}-", s)
Next s
Next x
End Sub 'Main
End Class 'StringSplit2

Hope it helps
Chris
"Dave" <no****@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
Greetings,

Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?

Thanks,

-Dave

Nov 21 '05 #5
"Dave" <no****@yahoo.com> schrieb:
Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?


\\\
Dim s As String = ...
Dim astr() As String = s.Split(ControlChars.Cr, " "c)
///

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

Nov 21 '05 #6
"Dave" <no****@yahoo.com> schrieb:
Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?


\\\
Dim s As String = ...
Dim astr() As String = s.Split(ControlChars.Cr, " "c)
///

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

Nov 21 '05 #7
Perfect. Thanks for all your help.

"Dave" <no****@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
Greetings,

Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?

Thanks,

-Dave

Nov 21 '05 #8
Perfect. Thanks for all your help.

"Dave" <no****@yahoo.com> wrote in message
news:uh**************@TK2MSFTNGP11.phx.gbl...
Greetings,

Is there a way I can split a string into an array on a space OR a carriage
return? What would the code look like for this?

Thanks,

-Dave

Nov 21 '05 #9

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

Similar topics

5
31154
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
4
728
by: William Stacey [MVP] | last post by:
Would like help with a (I think) a common regex split example. Thanks for your example in advance. Cheers! Source Data Example: one "two three" four Optional, but would also like to...
0
270
by: Dave | last post by:
Greetings, Is there a way I can split a string into an array on a space OR a carriage return? What would the code look like for this? Thanks, -Dave
5
5848
by: kurt sune | last post by:
The code: Dim aLine As String = "cat" & vbNewLine & "dog" & vbNewLine & "fox" & vbNewLine Dim csvColumns1 As String() = aLine.Split(vbNewLine, vbCr, vbLf) Dim csvColumns2 As String() =...
1
8347
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
2
1407
by: darkdirk1 | last post by:
I am trying to create a function that parses a string and creates an array with the values which will be seperated by either white space or and unknown number of carriage returns/linebreaks.... I...
22
2860
by: SmokeWilliams | last post by:
Hi, I am working on a Spell checker for my richtext editor. I cannot use any open source, and must develop everything myself. I need a RegExp pattern to split text into a word array. I have...
23
2796
by: KIRAN | last post by:
Hi all, can i split a C string like this? char * p = "Hello \ World\n\r"; is this according to standard? Any help or link to standard regarding the above doubt is aprreciated... Regards, Kiran
1
17419
code green
by: code green | last post by:
I have an address field in a table that contains one, two, three or more lines of an address. I need to split this into three fields for later insertion into CSV. I have done something similar...
0
7105
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,...
0
7132
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,...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5439
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,...
1
4870
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...
0
3076
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
266
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...

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.