Solved

c# string getting certain characters

Posted on 2014-01-04
3
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39756531
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
ID: 39758069
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
ID: 39760506
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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