473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Split strings whit strings

Hi, I would like split string with more than one separator, and assign the
result as array.

For example:

"car123house123truck123"

I need split my string in a array of 3 components

car
house
truck

How make that?

I try the split function (<chain.split("123")>), but I get
car
23house
23truck

Thanks in advance for any help.

Freddy Coal
Mar 2 '07 #1
3 1478
Freddy Coal wrote:
For example:
"car123house123truck123"
I try the split function (<chain.split("123")>), but I get
car
23house
23truck
Imports VB=Microsoft.VisualBasic

Dim s As String = VB.Split( chain, "123" )

Watch out for that trailing delimiter - you'll probably wind up with a
/four/-element array, with the last one being blank:

s(0) = "car"
s(1) = "house"
s(2) = "truck"
s(3) = (blank)

HTH,
Phill W.
Mar 2 '07 #2
freddy

Mostly is this problem the most simple to do by first changing the delimiter
using replace and than split it.

Cor

"Freddy Coal" <fr********@gmail.withoutspan.comschreef in bericht
news:ej**************@TK2MSFTNGP04.phx.gbl...
Hi, I would like split string with more than one separator, and assign the
result as array.

For example:

"car123house123truck123"

I need split my string in a array of 3 components

car
house
truck

How make that?

I try the split function (<chain.split("123")>), but I get
car
23house
23truck

Thanks in advance for any help.

Freddy Coal

Mar 2 '07 #3
Thanks a lot Phill, that is the perfect solution for me!

Freddy Coal

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-kwrote in message
news:es**********@south.jnrs.ja.net...
Freddy Coal wrote:
>For example:
"car123house123truck123"
>I try the split function (<chain.split("123")>), but I get
car
23house
23truck

Imports VB=Microsoft.VisualBasic

Dim s As String = VB.Split( chain, "123" )

Watch out for that trailing delimiter - you'll probably wind up with a
/four/-element array, with the last one being blank:

s(0) = "car"
s(1) = "house"
s(2) = "truck"
s(3) = (blank)

HTH,
Phill W.

Mar 2 '07 #4

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

Similar topics

6
by: Senthil | last post by:
Code ---------------------- string Line = "\"A\",\"B\",\"C\",\"D\""; string Line2 = Line.Replace("\",\"","\"\",\"\""); string CSVColumns = Line2.Split("\",\"".ToCharArray());
19
by: David Logan | last post by:
We need an additional function in the String class. We need the ability to suppress empty fields, so that we can more effectively parse. Right now, multiple whitespace characters create multiple...
10
by: mb | last post by:
I was wondering if there is an easy, more useful Split function that will split with a string delimiter like "<>" or "////"?
4
by: Itzik | last post by:
can i split this string string str = "aa a - bb-b - ccc" with this delimiter string del = " - " i want recieve 3 items : "aa a" , "bb-b" , "ccc"
14
by: Ron | last post by:
Hello, I am trying to parse a string on the newline char. I guess vbCrLf is a string constant. How can I parse my string - data - on the newline char? .... data += ASCII.GetString(buffer, 0,...
5
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() =...
7
by: lgbjr | last post by:
Hi All, I'm trying to split a string on every character. The string happens to be a representation of a hex number. So, my regex expression is (). Seems simple, but for some reason, I'm not...
2
by: Digital Fart | last post by:
following code would split a string "a != b" into 2 strings "a" and "b". but is there a way to know what seperator was used? string charSeparators = { "=", ">=", "<=" , "!=" }; string s1 =...
6
by: Bob Bedford | last post by:
Hi all, I've an XML file that takes more than the hosting time limit to be readed by a PHP script. What I'd like to do is split the large XML file (can be more than 30MB) in little parts and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.