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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:36:28+00:00 2026-06-06T00:36:28+00:00

I would like to split the following string generated from a database resultset row.

  • 0

I would like to split the following string generated from a database resultset row.

Sample rows:

A) (74,”and there”,”is a car”,”in the”,”garage man”,t)

B) (17,account3,,,,t)

I want an output as follows (Pipe | to separate split elements):

A) 74 | and there | is a car | in the | garage man | t

B) 17 | account3 | | | | t

I want to zero length values to be stored as null in my application. This is my source code:

public void refreshSearchTable (ArrayList<String> newData){
        int noOfRows = newData.size();
        int noOfColumns = gui.getTableSearchResultHeader().length + 1;
        Object[][] tempList = new Object[noOfRows][noOfColumns];
        String rowResult = "";
        String delims = "[,()\"]+";
        String [] tokens;
        Object [] elements = newData.toArray();

        int j = 0;
        for (int i = 0; i < noOfRows; i++){
            rowResult = elements[i].toString();
            System.out.println("rowresult: " + rowResult);
            tokens = rowResult.split(delims, -1);
            for (String t : tokens){

                System.out.println("j: " + j + "t: " + t);

                if (j == 1){ ... }
                else if (j==2){ ... }
                                ...

                j++;
            }
            j=0;
        }
    }

“[,()\”]+” works fine for non-zero length values. I’m able to pick up the right sub-string according to index value j. I’ve read that passing a negative value to split(, ) will not discard the non-zero length values … but it does. What am i doing wrong?

  • 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-06T00:36:29+00:00Added an answer on June 6, 2026 at 12:36 am

    Maybe you could try with .split("[()\"]*,{1}[()\"]*");

    The expression user before [,()\"]+ will use as separator more than one comma or any other separator informed. For instance ,, will be consider one, so does [],[]. The expression commented above, expects that zero or more of the separators are followed with just one comma and this can be followed with zero or more separators too.

    • 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 that I would like to split on the \xA7
I would like to split the string: Hello[You]All to the following array: H,e,l,l,o,[You],A,l,l I
I would like to split a string into fixed-length ( N , for example)
I would like to split one records columns into multiple rows. If I have
I would like to split a string by an array of characters, how would
I have a string in PHP that I would like to split. This string
I have the following string: I would surely like to go to school. Now,
Given the following text: This is!!xa simple string!xpattern I would like to get a
I would like to call the Java class file from compiling the following code:
I'd like to String.Split() the following string using a comma as the delimitter: John,Smith,123

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.