Solved

c# string getting certain characters

Posted on 2014-01-04
3
344 Views
Last Modified: 2014-01-12
Hi,

I have a string that gets displayed like so

ID: 223 Client Name: test

What I want to do is get the whole ID value

please help

Thanks

R8vI
0
Comment
Question by:R8VI
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
considering your other question:
http://www.experts-exchange.com/Programming/Languages/.NET/Q_28330657.html#a39756517

if you do apply that div technique to hide, you can quite easily do it with html or xml parser.
in any case, you can do it with a regular expression

using System.Text.RegularExpressions;

Match match = Regex.Match(your_string, @"ID:\s*([0-9]+)\s");

Open in new window

and the match object should give you the properties to get the ID value then.
0
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
You can use the Substring method of the string class.

If the ID is always 3 characters, then use the following:

yourString.Substring(4, 3);

Otherwise:

yourString.Substring(4,yourString.IndexOf(' ',4)-4);
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
Comment Utility
Hi,

I am confused for your question for how to answer it in which context.

Can you elaborate what you are trying to do and why? It will get you best answer for your question.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hangfire / asp.net sample 3 27
C# SQL BULK INSERT CLASS 5 33
Make a border less form movable 2 10
COnsume rest client 6 4
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now