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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:10:12+00:00 2026-06-18T06:10:12+00:00

This sample data is returned by Web Service 200,6, California, USA I want to

  • 0

This sample data is returned by Web Service

200,6, “California, USA”

I want to split them using split(",") and tried to see the result using simple code.

String loc = "200,6,\"California, USA\"";       
String[] s = loc.split(",");

for(String f : s)
   System.out.println(f);

Unfortunately this is the result

200
6
"California
 USA"

The expected result should be

200
6
"California, USA"

I tried different regular expressions and no luck. Is it possible to escape the given regular expression inside of "" ?

UPDATE 1: Added C# Code

UPDATE 2: Removed C# Code

  • 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-18T06:10:13+00:00Added an answer on June 18, 2026 at 6:10 am
    ,(?=(?:[^"]|"[^"]*")*$)
    

    This is the regex you want
    (To put it in the split function you’ll need to escape the quotes in the string)

    Explanation

    You need to find all ‘,’s not in quotes..
    That is you need lookahead (http://www.regular-expressions.info/lookaround.html) to see whether your current matching comma is within quotes or out.

    To do that we use lookahead to basically ensure the current matching ‘,’ is followed by an EVEN number of ‘”‘ characters (meaning that it lies outside quotes)

    So
    (?:[^"]|"[^"]*")*$ means match only when there are non quote characters till the end OR a pair of quotes with anything in between them

    (?=(?:[^"]|"[^"]*")*$) will lookahead for the above match

    ,(?=(?:[^"]|"[^"]*")*$) and finally this will match all ‘,’ with the above lookahead

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

Sidebar

Related Questions

Sample data: I can flatten out parent-child relationship using this query.... Any help... Thanks
I'm using SimpleXML to get pieces of data from an XML web-service response. We
I tried implementing a simple web service into an asp.net application using the tutorial
I have this simple web service, right now it just looks to see if
Following is the sample data. I need to make 3 copies of this data
I am trying to binary serialize the data of vector. In this sample below
Ok, I've got a list like this (just a sample of data): data =
My data is tab delimited and looks like this: Name Count Sample Dog .0001
Using this tutorial: http://www.c-sharpcorner.com/uploadfile/UrmimalaPal/creating-a-windows-phone-7-application-consuming-data-using-a-wcf-service/ I have created sample/hello world application on the windows phone
i have this simple code to load data from other php page using get

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.