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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:46:19+00:00 2026-05-27T06:46:19+00:00

I am looking at how to split a string and store the info in

  • 0

I am looking at how to split a string and store the info in a datatable. I can get the split and store to work correctly but the issue comes in how I am trying to use the split. this is an example of the string I have:

 itemid/n3,itemid/n4

itemid is the items unique id and after /n is how many of the item the user has selected, the comma seperates the entries

I have a data table like this:

DataTable table = new DataTable();
table.Columns.Add("id", typeof(int));
table.Columns.Add("count", typeof(int));

Id like to be able to split the string at the comma and then store each of the values in the data table so they appear on the same row (split at the /n) is there an easy way to do this using split? or am I better off doing it another way

  • 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-27T06:46:19+00:00Added an answer on May 27, 2026 at 6:46 am

    If “/n” and “,” are always present for each record, you can use a regular expression split with the expression “(?:/n|\,)” and then loop with x+=2 instead of x++ through the list. X will be the ID, X+1 will be the value.

    string Input = "12/nTwelve,13/nThirteen,";
    string[] InputSplit = Regex.Split(Input, @"(?:/n|\,)");
    for(int i = 0 ; i < ((InputSplit.Length / 2) * 2) ; i+=2){ 
        //Math in the middle helps when there's a trailing comma in the data set
        Console.WriteLine(string.Format("{0}\t{1}", InputSplit[i], InputSplit[i+1]));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking to split a string based on a regular expression but I
I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
Looking for some help! I need to split a string at the last occurrence
I'm looking for a way to split a Twitter permalink string on its final
What I'm looking to do is split data from string into an array. Here's
I'm looking for a way, in .NET, to split a string while ignoring split
I am looking to use this plugin: http://keith-wood.name/countdown.html but I need to use the
I'm looking at parsing a delimited string, something on the order of a,b,c But
I'm looking to split a string using Java if it contains a digit or
im trying to split a string in C (Not in C#, C++ or any

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.