Solved

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

Posted on 2009-04-13
2
482 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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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