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

  • SEARCH
  • Home
  • 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 8310265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:23:54+00:00 2026-06-08T19:23:54+00:00

I need to take a string and split it into an array based on

  • 0

I need to take a string and split it into an array based on the type of charcter not matching they proceeding it.

So if you have “asd fds 1.4#3” this would split into array as follows

stringArray[0] = "asd";
stringArray[1] = " ";
stringArray[2] = "fds";
stringArray[3] = " ";
stringArray[4] = "1";
stringArray[5] = ".";
stringArray[6] = "4";
stringArray[7] = "#";
stringArray[8] = "3";

Any recomendations on the best way to acheive this? Of course I could create a loop based on .ToCharArray() but was looking for a better way to achieve this.

Thank you

  • 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-08T19:23:56+00:00Added an answer on June 8, 2026 at 7:23 pm

    Using a combination of Regular Expressions and link you can do the following.

    using System.Text.RegularExpressions;
    using System.Linq;
    
    var str="asd fds 1.4#3";
    var regex=new Regex("([A-Za-z]+)|([0-9]+)|([.#]+)|(.+?)");
    
    var result=regex.Matches(str).OfType<Match>().Select(x=>x.Value).ToArray();
    

    Add additional capture groups to capture other differences. The last capture (.+?) is a non greedy everything else. So every item in this capture will be considered different (including the same item twice)

    Update – new revision of regex

    var regex=new Regex(@"(?:[A-Za-z]+)|(?:[0-9]+)|(?:[#.]+)|(?:(?:(.)\1*)+?)");
    

    This now uses non capturing groups so that \1 can be used in the final capture. This means that the same character will be grouped if its in then catch all group.

    e.g. before the string “asd fsd” would create 4 strings (each space would be considered different) now the result is 3 strings as 2 adjacent spaces are combined

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

Sidebar

Related Questions

I first take a string input and change it into a split array, but
I'm looking to take a string and break it into an array at line
I am doing RSA encryption and I have to split my long string into
Need to take a string in vb and split it. Also need to look
In my project i need to take an expression input from user as string
In my project I take a string from user and then I need to
i need to take some row. They came from sql TARIH (sql column) is
I need to take a url, /ServiceSearch/r.php?n=blahblah, and have it go to /search/blahblah/ so
I want to take input from a textfield and turn it into an array
I need to convert minutes (defined as Integer) into the following String format hh:mm

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.