473,796 Members | 2,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

separating a string delimited by "|" and storing in variables

VM
How can I separate a string that looks like this:

"John|Conner|34 323|T3-1"

so I can place John in one variable, Conner in another variable, etc...?

I know you can do it by finding the special char ('|' in this case) and
calculating the size of the string, but there should be a faster way.

Thanks,
VM
Nov 16 '05 #1
2 1770
"VM" <vo******@yahoo .com> wrote in message
news:OH******** ******@TK2MSFTN GP10.phx.gbl...
How can I separate a string that looks like this:

"John|Conner|34 323|T3-1"

so I can place John in one variable, Conner in another variable, etc...?

I know you can do it by finding the special char ('|' in this case) and
calculating the size of the string, but there should be a faster way.

Thanks,
VM


string myString = "John|Conner|34 323|T3-1";
string[] myStrings = myString.Split( '|');

Erik
Nov 16 '05 #2
VM
Thanks. Works great.
"Erik Frey" <er*******@hotm ail.com> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
"VM" <vo******@yahoo .com> wrote in message
news:OH******** ******@TK2MSFTN GP10.phx.gbl...
How can I separate a string that looks like this:

"John|Conner|34 323|T3-1"

so I can place John in one variable, Conner in another variable, etc...?

I know you can do it by finding the special char ('|' in this case) and
calculating the size of the string, but there should be a faster way.

Thanks,
VM


string myString = "John|Conner|34 323|T3-1";
string[] myStrings = myString.Split( '|');

Erik

Nov 16 '05 #3

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

Similar topics

11
4977
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g., http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=Tidy7IDbDHA.2108%40cpmsftngxa06.phx.gbl) that indicate that ASP will queue up requests when they come in with the same "session".
18
2583
by: Kevin Grigorenko | last post by:
Okay, i've got a file open, call it infile. I've got a simple while(!eof), but say the first line of my file is "<?xml version="1.0">", then it takes two iterations to get the string. first 'line' is "<?xml", then 'line' is "version="1.0"", what's happening that I need to change the behavior of so that I can get lines delimitted by the newlines in the file? std::string line; std::ifstream infile("whatever.txt", std::ios_base::in);...
11
4223
by: Paul D.Smith | last post by:
Can Python create a variable "on-the-fly". For example I would like something like... make_variable('OSCAR', 'the grouch'); print OSCAR; ....to output... the grouch
134
7919
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that means that if I misspell a variable name, my program will mysteriously fail to work with no error message. If you don't declare variables, you can inadvertently re-use an variable used in an enclosing context when you don't intend to, or
2
2322
by: Ray Stevens | last post by:
I am loading a pipe-delimited string from a DataSet into StringBuilder, such as 00P|23423||98723 (etc.). For some reason the pipe character is displaying in the debugger as "o" with two small dots on top (i.e., with an umlaut). Is StringBuilder modifying my pipe character and, if so, how do I stop it?
5
12099
by: Yan | last post by:
hi, I need to connect a csv file as data source. the connection string currently using is cnxStr = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + CSVFolder + ";Extended Properties=""Text;HDR=No;FMT=Delimited;IMEX=1\""" it's working, however it's only able to read a row as one column. I have multiple columns in a row, delimited by pipe (|). What's the variables i need to add/change to the connection string in order for it to be...
15
3085
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 pipe symbol .for example you can use something like this AddRole("My Group", "Test", 0x10000000|0x00000002);
2
2548
by: gh | last post by:
Hi, I have a string variable which contains n number of comma delimited elements and I would like to store each element into an array but I could not figure how to do it. for example, 1stitem,2nditem,3rditem,4thitem, ..., nthitem What would be the best way of storing the above string into an array like
41
2555
by: none | last post by:
Hello, IIRC, I once saw an explanation how Python doesn't have "variables" in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? Thanks, Ami
0
9684
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
9530
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
10459
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
10236
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
9055
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
7552
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
6793
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
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3734
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.