473,324 Members | 2,124 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,324 software developers and data experts.

Delimited Strings

Supposing I have a string containing fields delimited by | (pipe) such as:

this|is|a|string|delimited|by|pipes

If I wanted to get the portion of the string between the 3rd and 4th pipe,
I would have to start at the beginning of the entire string and inspect each
character to see if it is a pipe. Once I found the 3rd pipe, I could begin
parsing the string until a 4th pipe is discovered.

Is there a simpler and more elegant way to do this? There must be...

Thanks,
Mark

Nov 21 '05 #1
8 1509
regex.split

"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Supposing I have a string containing fields delimited by | (pipe) such as:

this|is|a|string|delimited|by|pipes

If I wanted to get the portion of the string between the 3rd and 4th pipe,
I would have to start at the beginning of the entire string and inspect each
character to see if it is a pipe. Once I found the 3rd pipe, I could begin
parsing the string until a 4th pipe is discovered.

Is there a simpler and more elegant way to do this? There must be...

Thanks,
Mark

Nov 21 '05 #2
regex.split

"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Supposing I have a string containing fields delimited by | (pipe) such as:

this|is|a|string|delimited|by|pipes

If I wanted to get the portion of the string between the 3rd and 4th pipe,
I would have to start at the beginning of the entire string and inspect each
character to see if it is a pipe. Once I found the 3rd pipe, I could begin
parsing the string until a 4th pipe is discovered.

Is there a simpler and more elegant way to do this? There must be...

Thanks,
Mark

Nov 21 '05 #3
"Mark Jones" <no**************@devnullbucket.org> schrieb:
regex.split


.... or 'Strings.Split' (in VB.NET).

--
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 #4
"Mark Jones" <no**************@devnullbucket.org> schrieb:
regex.split


.... or 'Strings.Split' (in VB.NET).

--
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 #5
But your way will be the fastest since you know what you are going for.

You can use:

String.Split(Seperator as char, count as integer) as string()

That does the same thing you do, and returns an array of strings

Chris
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Supposing I have a string containing fields delimited by | (pipe) such as:

this|is|a|string|delimited|by|pipes

If I wanted to get the portion of the string between the 3rd and 4th
pipe,
I would have to start at the beginning of the entire string and inspect
each
character to see if it is a pipe. Once I found the 3rd pipe, I could
begin
parsing the string until a 4th pipe is discovered.

Is there a simpler and more elegant way to do this? There must be...

Thanks,
Mark

Nov 21 '05 #6
But your way will be the fastest since you know what you are going for.

You can use:

String.Split(Seperator as char, count as integer) as string()

That does the same thing you do, and returns an array of strings

Chris
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Supposing I have a string containing fields delimited by | (pipe) such as:

this|is|a|string|delimited|by|pipes

If I wanted to get the portion of the string between the 3rd and 4th
pipe,
I would have to start at the beginning of the entire string and inspect
each
character to see if it is a pipe. Once I found the 3rd pipe, I could
begin
parsing the string until a 4th pipe is discovered.

Is there a simpler and more elegant way to do this? There must be...

Thanks,
Mark

Nov 21 '05 #7
Thanks!!

Mark

"Mark" wrote:
Supposing I have a string containing fields delimited by | (pipe) such as:

this|is|a|string|delimited|by|pipes

If I wanted to get the portion of the string between the 3rd and 4th pipe,
I would have to start at the beginning of the entire string and inspect each
character to see if it is a pipe. Once I found the 3rd pipe, I could begin
parsing the string until a 4th pipe is discovered.

Is there a simpler and more elegant way to do this? There must be...

Thanks,
Mark

Nov 21 '05 #8
Thanks!!

Mark

"Mark" wrote:
Supposing I have a string containing fields delimited by | (pipe) such as:

this|is|a|string|delimited|by|pipes

If I wanted to get the portion of the string between the 3rd and 4th pipe,
I would have to start at the beginning of the entire string and inspect each
character to see if it is a pipe. Once I found the 3rd pipe, I could begin
parsing the string until a 4th pipe is discovered.

Is there a simpler and more elegant way to do this? There must be...

Thanks,
Mark

Nov 21 '05 #9

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

Similar topics

10
by: Mark Harrison | last post by:
What is the best way to process a text file of delimited strings? I've got a file where strings are quoted with at-signs, @like this@. At-signs in the string are represented as doubled @@. ...
9
by: Dr. StrangeLove | last post by:
Greetings, Let say we want to split column 'list' in table lists into separate rows using the comma as the delimiter. Table lists id list 1 aa,bbb,c 2 e,f,gggg,hh 3 ii,kk 4 m
4
by: Vagabond Software | last post by:
Apparently, the Split method handles consecutive tabs as a single delimiter. Does anyone have any suggestions for handling consecutive tabs? I am reading in text files that contain lines of...
5
by: Christine | last post by:
I have code right now that reads in the file into an arraylist, but it reads in each line of the text file as a single element rather than the separate tab delimited strings in the line. Is there...
2
by: Ot | last post by:
I have a Tab delimited file: Field1<tab>Field2<tab>...<Field20><crlf> There must be an easy way to break this apart, but I haven't found it yet. Can anyone help? Regards, Ot
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
25
by: electrixnow | last post by:
in MS VC++ Express I need to know how to get from one comma delimited text string to many strings. from this: main_string = "onE,Two,Three , fouR,five, six " to these: string1 =...
15
by: Fariba | last post by:
Hello , I am trying to call a mthod with the following signature: AddRole(string Group_Nam, string Description, int permissionmask); Accroding to msdn ,you can mask the permissions using...
4
by: siromega | last post by:
I have a string I'd like to have broken into parts using preg_match. I used a regular expression from the Perl FAQ (http://perlfaq.cpan.org/): push(@new, $+) while $text =~ m{ "(*(?:\\.*)*)",?...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.