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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:09:06+00:00 2026-06-16T00:09:06+00:00

I am looking to split such string by comma : field1:value1, field2:value2, field3:value3,value4 into

  • 0

I am looking to split such string by comma :

 field1:"value1", field2:"value2", field3:"value3,value4"

into a string[] that would look like:

0     field1:"value1"
1     field2:"value2"
2     field3:"value3,value4"

I am trying to do that with Regex.Split but can’t seem to work out the regular expression.

  • 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-16T00:09:07+00:00Added an answer on June 16, 2026 at 12:09 am

    It’ll be much easier to do this with Matches than with Split, for example

    string[] asYouWanted = Regex.Matches(input, @"[A-Za-z0-9]+:"".*?""")
        .Cast<Match>()
        .Select(m => m.Value)
        .ToArray();
    

    although if there is any chance of your values (or fields!) containing escaped quotes (or anything similarly tricky), then you might be better off with a proper CSV parser.


    If you do have escaped quotes in your values, I think the following regex the work – give it a test:

    @"field3:""value3\\"",value4""", @"[A-Za-z0-9]+:"".*?(?<=(?<!\\)(\\\\)*)"""
    

    The added (?<=(?<!\\)(\\\\)*) is supposed to make sure that the " it stops matching on is preceeded by only an even number of slashes, as an odd number of slashes means it is escaped.

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

Sidebar

Related Questions

I am looking for a algorithm that takes a string and splits it into
I am looking to be able to split a string into a list around
I would like some guidance on how to split a string into N number
I have a code-base that I'm looking to split up and add to by
Looking for some help! I need to split a string at the last occurrence
I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
I have a string such as the following: Are you looking for a quality
Given a table-valued function such as dbo.Split() from T-SQL: Opposite to string concatenation -
I'm looking to split space-delimited strings into a series of search terms. However, in
In T E X, how is it possible to split a string such as

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.