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 7906517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:00:42+00:00 2026-06-03T11:00:42+00:00

I have the following string in C#. aaa,bbbb.ccc|dddd:eee I then split it with new

  • 0

I have the following string in C#.

"aaa,bbbb.ccc|dddd:eee"

I then split it with new char[] {',','.','|',':'}. How would I rejoin this string in the same order as before with the same characters? So the list would end up the exact same as it was before.

EXAMPLE

string s = "aaa,bbbb.ccc|dddd:eee";
string[] s2 = s.Split(new char[] {',','.','|',':'});
// now s2 = {"aaa", "bbbb", "ccc", "dddd", "eee"}
// lets assume I done some operation, and
// now s2 = {"xxx", "yyy", "zzz", "1111", "222"}

s = s2.MagicJoin(~~~~~~);  // I need this

// now s = "xxx,yyy.zzz|1111:222";

EDIT

the char[] in above sample just sample, not in same order or even will not all appear in same time in real world.

EDIT

Just a thought, how about use Regex.split, then first split by char[] get a string[], then use not the char[] to split get another string[], later just put them back. Maybe work but I do not know how to code it.

  • 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-06-03T11:00:47+00:00Added an answer on June 3, 2026 at 11:00 am

    It might be easier to do this with the Regex class:

    input = Regex.Replace(input, @"[^,.|:]+", DoSomething);
    

    Where DoSomething is a method or lambda that transforms the item in question, e.g.:

    string DoSomething(Match m)
    {
        return m.Value.ToUpper();
    }
    

    For this example the output string for “aaa,bbbb.ccc|dddd:eee” would be “AAA,BBBB.CCC|DDDD:EEE”.

    If you use a lambda you can very easily keep state around, like this:

    int i = 0;
    Console.WriteLine(Regex.Replace("aaa,bbbb.ccc|dddd:eee", @"[^,.|:]+",
        _ => (++i).ToString()));
    

    Outputs:

    1,2.3|4:5
    

    It just depends on what kind of transformation you’re doing to the items.

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

Sidebar

Related Questions

I have the following string: const char *str = \This is just some random
Have the following string i need to split. $string = This is string sample
I have following String and i want to split this string into number of
I have the following String First Last <first.last@email.com> I would like to extract first.last
I have the following string: <div id=mydiv>This is a div with quotation marks</div> I
I have following code: string date = 13.04.2012; string date2 = (DateTime.Parse(date).AddDays(1)).ToString(); This is
I have following string hello[code:1], world [code:2], hello world I want to replace this
Have following String built SQL query: StringBuilder querySelect = new StringBuilder(select * from messages
Suppose I have following string: String asd = this is test ass this is
I have the following code: public class TestGr { static String aaa = wwww;

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.