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

Parsing

How can I parse easily the following line:

Hi There How "Are you?"

I need to obtain the following values:

1- Hi
2- There
3- How
4- Are You?

Can I use some string tokenisation with this? Can I use the String.Split
member function? How will I treat the "" ?

Thank you
Nov 15 '05 #1
4 1804
what's the deal with the Are You? on one line. The rest you can split on a
blank but I don't know your reason for Are You? Was that a typo?

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Michel Racicot" <mi*********************@cgi.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
How can I parse easily the following line:

Hi There How "Are you?"

I need to obtain the following values:

1- Hi
2- There
3- How
4- Are You?

Can I use some string tokenisation with this? Can I use the String.Split
member function? How will I treat the "" ?

Thank you

Nov 15 '05 #2
The most direct way would be to use a regular expression. (In the
System.Text.RegularExpressions namespace.)

If you use this pattern for a regular expression:
(?<=").+(?=")|[^\s"]+

You will get the following matches on your text:
Hi
There
How
Are you?

In plain English, the pattern reads as "one or more characters preceeded by
a quotation mark and followed by a quotation mark, OR one or more of any
character except for a whitespace character or quotation mark." It's not
very intuitive, but it works.
"Michel Racicot" <mi*********************@cgi.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
How can I parse easily the following line:

Hi There How "Are you?"

I need to obtain the following values:

1- Hi
2- There
3- How
4- Are You?

Can I use some string tokenisation with this? Can I use the String.Split
member function? How will I treat the "" ?

Thank you

Nov 15 '05 #3
It looks like he wants to keep anything surrounded by quotations as a single
line. Unfortunately, String.Split won't work for something like that.
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
what's the deal with the Are You? on one line. The rest you can split on a
blank but I don't know your reason for Are You? Was that a typo?

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Michel Racicot" <mi*********************@cgi.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
How can I parse easily the following line:

Hi There How "Are you?"

I need to obtain the following values:

1- Hi
2- There
3- How
4- Are You?

Can I use some string tokenisation with this? Can I use the String.Split member function? How will I treat the "" ?

Thank you


Nov 15 '05 #4
right, i assumed it was a typo (actually didn't see the quote :-) and he
wanted a simple split. yes that regex will work just fine if thats what he
wants to do.

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Robert Jacobson" <rj**********************@nospam.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
It looks like he wants to keep anything surrounded by quotations as a single line. Unfortunately, String.Split won't work for something like that.
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
what's the deal with the Are You? on one line. The rest you can split on a
blank but I don't know your reason for Are You? Was that a typo?

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Michel Racicot" <mi*********************@cgi.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
How can I parse easily the following line:

Hi There How "Are you?"

I need to obtain the following values:

1- Hi
2- There
3- How
4- Are You?

Can I use some string tokenisation with this? Can I use the

String.Split member function? How will I treat the "" ?

Thank you



Nov 15 '05 #5

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
0
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
5
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
7
by: Daniel Fetchinson | last post by:
Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is yesterday I would like to see "yesterday" instead of the date itself. And for...
1
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...
0
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
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,...
0
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...

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.