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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:55:42+00:00 2026-06-03T18:55:42+00:00

Suppose you’re dealing with data organized in the following format: [123]=some string [234]=999999999 [345]=some

  • 0

Suppose you’re dealing with data organized in the following format:

[123]="some string" [234]=999999999 [345]="some other string"

In Java, what would be the easiest way to split each by KV combination, where K is the tag (enclosed in [ ]).

Is there a Utils (Apache or other?) method you know off that lets you define a structure as shown above to help with iterating over it, instead of having to manually count and read data past and between [ ]?

What do we know?

  • Each element will have a tag
  • Each tag will be surrounded by [ ]
  • Tag and value assigned to the tag will be separated by =
  • Value will be there. No empty values allowed.
  • Value may or may not be surrounded by quotes
  • 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-03T18:55:43+00:00Added an answer on June 3, 2026 at 6:55 pm

    Use a Pattern with regex "\\[(.*?)\\]=(.*?)( (?=\\[)|$)" to grab pairs at a time.
    The only limitation is that the next term is assumed to start at a space followed by a [, so this character sequence may not appear within a value.

    This code demonstrates:

    public static void main(String[] args) {
        String input = "[123]=\"some string\" [234]=999999999 [345]=\"some other string\"";
        Pattern pattern = Pattern.compile("\\[(.*?)\\]=(.*?)( (?=\\[)|$)");
        Matcher matcher = pattern.matcher(input);
        while (matcher.find()) {
            String k = matcher.group(1);
            String v = matcher.group(2);
            System.out.println(k + "-->" + v);
        }
    }
    

    Output:

    123-->"some string"
    234-->999999999
    345-->"some other string"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we have the following: data Foo x from_list :: [x] -> Foo x
Suppose I have the following table: PERSON : ID INT NAME STRING LASTNAME STRING
Suppose a mysql 5.5 server uses the following configuration for storing innodb data innodb_data_file_path
suppose we have this next sample code: while(some condition){ lock1.lock(); . . } the
Suppose the following constructor: class Needed { public: Needed () {} Needed (const char
Specifically, suppose I start with the string string =hello \'i am \' me And
Suppose I have a data frame, df, that looks like: f t1 t2 t3
suppose I have the following serial C: int add(int* a, int* b, int n)
Suppose I have the following two tables: STUDENT studentid lastname firstname 1 Smith John
Suppose I have the following HTML: <div id=Wrapper> <div class=MyClass></div> <div class=MyClass></div> <div class=MyClass></div>

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.