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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:03:56+00:00 2026-06-18T02:03:56+00:00

I have a string like this – fruit=apple man=human abc=123 I want values to

  • 0

I have a string like this –

"fruit=apple man=human abc=123"

I want values to be printed like –

fruit=
apple
man=
human
abc=
123

i.e. I also want to see the delimeter values. Currently I’m trying-

String status2="fruit=apple man=human abc=123";
Scanner scn = new Scanner(status2).useDelimiter("[a-z]*=+");
while(scn.hasNext())
{
    System.out.println(scn.next());
    System.out.println(scn.delimiter());
}

But I cannot see the delimeter values

apple 
[a-z]*=+
human 
[a-z]*=+
123
[a-z]*=+

Updated String –

"cobdate=01/28/2013 fundsnotextracted= elapsedtime=00:06:02 user=dataprod starttime=Wed, 30 Jan 2013 11:50:30 periods=DAILY, MTD, YTD knowledgedate=01/30/2013:11:50:10 progress=67 statusstep=Generating Reports ....."

Expected output –

cobdate=01/28/2013 
fundsnotextracted= 
elapsedtime=00:06:02 
user=dataprod 
starttime=Wed, 30 Jan 2013 11:50:30 
periods=DAILY, MTD, YTD 
knowledgedate=01/30/2013:11:50:10 
progress=67 
statusstep=Generating Reports .....
  • 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-18T02:03:57+00:00Added an answer on June 18, 2026 at 2:03 am

    Your delimiter is not correct. You should set your delimiter after each = sign, and also at every whitespace. You can use this insead: –

    Scanner scn = new Scanner(status2).useDelimiter("(?<==)|[ ]");
    

    Here the delimiter is: – empty string following every = denoted by (?<==) or a whitespace denoted by [ ].


    However, given your input string, and the required output, I would rather split the string, with the same pattern as I used in the delimiter, which will give you an array, that you can also use somewhere else later on: –

    String status2="fruit=apple man=human abc=123";
    String[] arr = status2.split("(?<==)|[ ]");
    System.out.println(Arrays.toString(arr));
    

    Update: –

    For your updated input, you would have to do some more work. First of all, you strictly need a split here. Plus, you would have to do the split twice – once on a whitespace, and another on a =.

    Now, your whitespace must be followed by a sequence of alphabets ending with =, so that you don’t mistakenly split on the whitespace contained in the values. So, your code should look like this: –

    String str = "cobdate=01/28/2013 fundsnotextracted= elapsedtime=00:06:02 user=dataprod starttime=Wed, 30 Jan 2013 11:50:30 periods=DAILY, MTD, YTD knowledgedate=01/30/2013:11:50:10 progress=67 statusstep=Generating Reports .....";
    
    // Split on a whitespace, followed by a sequence of letters ending with =.
    // This ensures that you don't split on whitespace, optionally present in some values
    String[] arr = str.split("[ ](?=[a-zA-Z]+=)");
    
    for (String eachString : arr) {
        // Split on empty string following the = sign
        String[] tempArr = eachString.split("(?<==)");
    
        System.out.print(tempArr[0] + " ");
    
        // To ensure that you don't print a non-existence value.
        if (tempArr.length == 2) {
            System.out.println(tempArr[1]);
        } else {
            System.out.println();
        }
     }
    

    Output: –

    cobdate= 01/28/2013
    fundsnotextracted= 
    elapsedtime= 00:06:02
    user= dataprod
    starttime= Wed, 30 Jan 2013 11:50:30
    periods= DAILY, MTD, YTD
    knowledgedate= 01/30/2013:11:50:10
    progress= 67
    statusstep= Generating Reports ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have string like this $string = '$foo$wow$123$$$ok$'; i want to return empty string
I have a string like this field1=1 field2=2 field3=abc I want to ouput this
I have a string like this: Please refer to document ABC.123.1234.1234 and document CBA.321.4321
I have string looking like this: 'Toy Story..(II) (1995)' I want to split the
I have a string like this in C#: string a = A|B|C|D I want
I have a string like this: http://x.com/xyz/2013/01/16/zz/040800.php I want to get two strings from
I have a string like This is a test . I want to split
I have a string like this: S=str1|str2|str3 I want extract another string from S
I have string like this This is ~test content ~ok ~fine. I want to
I have a string like this HelloWorldMyNameIsCarl and I want it to become something

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.