Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSIS On fail action 5 49
Dynamics CRM Plugin Query TotalRecordCount returning -1 13 58
Need to sort columns in DataGridView 4 36
C# LINQ 5 23
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

756 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