PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Compact Framework String Parsing

Reply

String Parsing

 
Thread Tools Rate Thread
Old 08-03-2006, 05:39 PM   #1
Beebs
Guest
 
Posts: n/a
Default String Parsing


I have what probably is a simple question. I have a string like this:

Wednesday, March 08, 2006

I need to separate four values out of this without the white spaces.
First I need the day "Wednesday", then I need the Month, "March", then
the number day "08", then the year, "2006".

Can anyone tell me where to find a similar example or can someone
provide a code snippet that would show me what I need to do. Three of
the values can go by the comma locations and chop off the white space
I assume, the number day is probably a little harder to get out
though.

Thanks
  Reply With Quote
Old 08-03-2006, 07:25 PM   #2
shrenik
Guest
 
Posts: n/a
Default Re: String Parsing

Annoyingly lame solution...but since you're asking for it

yourDateString = yourDateString.Replace(",",""); // removes the commas
string[] list = yourDateString.Split[" "]; // splits the string at the
spaces
string day = list[0];
string month = list[1];
string date = list[2];
string year = list[3];

  Reply With Quote
Old 08-03-2006, 09:18 PM   #3
Brian Nantz
Guest
 
Posts: n/a
Default Re: String Parsing

Or you could load that into a DateTime and access the DateTime.Day etc...

shrenik wrote:
> Annoyingly lame solution...but since you're asking for it
>
> yourDateString = yourDateString.Replace(",",""); // removes the commas
> string[] list = yourDateString.Split[" "]; // splits the string at the
> spaces
> string day = list[0];
> string month = list[1];
> string date = list[2];
> string year = list[3];
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off