Solved

c# string getting certain characters

Posted on 2014-01-04
3
353 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

696 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