Solved

How to extract all characters after the first "_" (Easy)

Posted on 2009-04-13
2
481 Views
Last Modified: 2013-12-17
I know there are a few ways to do this, but what would be the simplest way to grab all characters after the first "_"?

Example:
string SomeString1 = "a_1234_dc_54";
string SomeString2 = "be_456_xy";

Results:
1234_dc_54
456_xy
0
Comment
Question by:_agx_
[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
2 Comments
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 24134465
Something like:


            string s = "a_1234_dc_54";
            int index = s.IndexOf("_");
            string s2 = s.Substring(index + 1);
            char[] chars= s2.ToCharArray();
            MessageBox.Show(s2);

Open in new window

0
 
LVL 52

Author Closing Comment

by:_agx_
ID: 31569747
Yes, that is what I was looking for. Thanks!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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