Solved

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

Posted on 2009-04-13
2
476 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_
2 Comments
 
LVL 29

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

803 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