Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 997981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:07:17+00:00 2026-05-16T07:07:17+00:00

This is my first stack message. Hope you can help. I have several strings

  • 0

This is my first stack message. Hope you can help.

I have several strings i need to break up for use later. Here are a couple of examples of what i mean….

fred-064528-NEEDED  
frederic-84728957-NEEDED  
sam-028-NEEDED

As you can see above the string lengths vary greatly so regex i believe is the only way to achieve what i want. what i need is the rest of the string after the second hyphen (‘-‘).

i am very weak at regex so any help would be great.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:07:18+00:00Added an answer on May 16, 2026 at 7:07 am

    Something like this. It will take anything (except line breaks) after the second ‘-‘ including the ‘-‘ sign.

    var exp = @"^\w*-\w*-(.*)$";
    
    var match = Regex.Match("frederic-84728957-NEE-DED", exp);
    
    if (match.Success)
    {
        var result = match.Groups[1]; //Result is NEE-DED
    
        Console.WriteLine(result);
    }
    

    EDIT: I answered another question which relates to this. Except, it asked for a LINQ solution and my answer was the following which I find pretty clear.

    Pimp my LINQ: a learning exercise based upon another post

    var result = String.Join("-", inputData.Split('-').Skip(2));
    

    or

    var result = inputData.Split('-').Skip(2).FirstOrDefault(); //If the last part is NEE-DED then only NEE is returned.
    

    As mentioned in the other SO thread it is not the fastest way of doing this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope anyone can help. I have to develop up against this third party
This is my first question on Stack Overflow, so I hope that I'm clear
I would like to have this behavior in a task history stack: First task
This is my first post on stack overflow, so I apologize if I have
This is the first time i'm asking a question here at stack overflow so
First off - hello, this is my first Stack Overflow question so I'll try
this is my first question on stack overflow. Some quick background, this is not
This is my first post on Stack Overflow and I'm just wondering on the
This is my first post on Stack, so please bear with me if I
( Preface: This is my first audio-related question on Stack Overflow, so I'll try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.