[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

c# string getting certain characters

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
R8VI
Asked:
R8VI
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
Jacques Bourgeois (James Burger)PresidentCommented:
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
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now