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

Parsing Strings

Hello,
How would I parse "Mel" from the string? "Sent by Mel @4:20"

Thanks
Mel
Nov 16 '05 #1
4 1324
If you simply wanted to see if the string contained the substring:

string myString = "Sent by Mel @4:20";
bool found = false;
if (myString.IndexOf("Mel") >= 0)
{
found = true;
}

Pete

"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message
news:OT**************@TK2MSFTNGP11.phx.gbl...
Hello,
How would I parse "Mel" from the string? "Sent by Mel @4:20"

Thanks
Mel

Nov 16 '05 #2
If I understand you correct you want to extract the name "Mel" from the
string ( Mel is in this case )
if i'm correct you can use regular expressions.
the paterrn that i've test is
^Sent by (?'Name'\w+) @.+
so to get the string in the group "Name" you can use:

Regex r = new Regex("Sent by Mel @4:20");

Match m = r.Match ( "^Sent by (?'Name'\w+) @.+" );

Console.WriteLine(m.Groups["Name"].Value);

Regards

Martin
"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message
news:OT**************@TK2MSFTNGP11.phx.gbl...
Hello,
How would I parse "Mel" from the string? "Sent by Mel @4:20"

Thanks
Mel

Nov 16 '05 #3
Hi Mel,

If strings are always in this format and you want to see who sent it this would do it.

string source = "Sent by Mel @4:20";
string sender = source.Split(null)[2];

The code splits the string into an array of words, where the sender is the 3rd word, index 2.

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4
Thank you very much

Mel

"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opr800uhvzklbvpo@qwerty...
Hi Mel,

If strings are always in this format and you want to see who sent it this would do it.
string source = "Sent by Mel @4:20";
string sender = source.Split(null)[2];

The code splits the string into an array of words, where the sender is the 3rd word, index 2.
Happy coding!
Morten Wennevik [C# MVP]

Nov 16 '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: Peter Sprenger | last post by:
Hello, I hope somebody can help me with my problem. I am writing Zope python scripts that will do parsing on text for dynamic webpages: I am getting a text from an oracle database that contains...
10
by: Christopher Benson-Manica | last post by:
(if this is a FAQ, I apologize for not finding it) I have a C-style string that I'd like to cleanly separate into tokens (based on the '.' character) and then convert those tokens to unsigned...
4
by: Gert Van den Eynde | last post by:
Hi all, Could you give me some pointers on how to parse a text input file in C++? Most will be config-file style input (keyword = data), but some maybe 'structures' like material{ name = n,...
4
by: ralphNOSPAM | last post by:
Is there a function or otherwise some way to pull out the target text within an XML tag? For example, in the XML tag below, I want to pull out 'CALIFORNIA'. ...
6
by: Ulrich Vollenbruch | last post by:
Hi all! since I'am used to work with matlab for a long time and now have to work with c/c++, I have again some problems with the usage of strings, pointers and arrays. So please excuse my basic...
12
by: Simone Mehta | last post by:
hi All, I am parsing a CSV file. I want to read every row into a char array of reasonable size and then extract strings from it. <snippet> char foo="hello,world,bye,bye,world"; ........
7
by: Lucas Tam | last post by:
Hi all, Does anyone know of a GOOD example on parsing text with text qualifiers? I am hoping to parse text with variable length delimiters/qualifiers. Also, qualified text could run onto...
18
by: Atara | last post by:
In my apllication I use the following code: '-- My Code: Public Shared Function strDate2Date(ByVal strDate As String) As System.DateTime Dim isOk As Boolean = False If (strDate Is Nothing)...
6
by: bwaichu | last post by:
I am writing a very basic web server, and I need to parse the HTTP Request string that I am receiving. Are there any good C books that suggest ways to parse strings effectively? Thanks!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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
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
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.