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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:03:32+00:00 2026-05-28T20:03:32+00:00

Is there any open source solution, or a generic regex for parsing name-value (key-value)

  • 0

Is there any open source solution, or a generic regex for parsing name-value (key-value) pairs out of a random String, in Java, with the (optional) delimiters stripped out?

From a Regular expression for parsing name value pairs, one such regex could be

"((?:\"[^\"]*\"|[^=,])*)=((?:\"[^\"]*\"|[^=,])*)"

However, the above (and its variations on the aforementioned question), although working as expected, return the delimiters along with the value.

For instance, a pair like key="value" will produce {key, “value”} instead of {key, value}.

The latter form of output would be nicer, since it avoids string post-processing to remove the enclosing delimiters (quotes in this case).

  • 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-05-28T20:03:34+00:00Added an answer on May 28, 2026 at 8:03 pm

    If you want to make the form adhere to optional quotes without them contained in either the key or value captures, you can do something like this (using your regex as an example, and including possible single quotes as delimeters as well).

    Capture buffers 2,4 contain key,value pairs (without quotes).

    "
     (['\"]?)  ([^'\"=,]+)  \1
     =
     (['\"]?)  ([^'\"=,]+)  \3
    "
    

    But this will collect possible garbage values separated by = sign.
    I think its better to provide a class that includes limited acceptable valeus instead.

    Something like this is what I would use.

    "
     (['\"]?) \s* (\w[-:\s\w]*?) \s* \1
     \s* = \s*
     (['\"]?) \s* (\w[-:\s\w]*?) \s* \3
    "
    

    possible greedy version

    \w+ (?: \s+[-:\w]+ )*
    or
    [-:\w]+ (?: \s+[-:\w]+ )*

    in this

    "
     (['\"]?) \s* (\w+(?:\s+[-:\w]+)*) \s* \1
     \s* = \s*
     (['\"]?) \s* (\w+(?:\s+[-:\w]+)*) \s* \3
    "
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any streaming server or solution preferably open-source solution exist for streaming MP4/AVI
I'm wondering is there any open-source solution for web-book creation like The Django Book
Are there any open-source libraries that all programmers should know about? I'm thinking something
Are there any open source or commercial web programming language that function much like
Is there any open source OCR library written in .NET, or written in any
Is there any open source Object Database available? I would like to have a
is there any open source or use Environment Picker in dotnet that allows me
Are there any open source frameworks that are for this purpose? How does UI
Are there any open-source compression/decomp libraries available for Ruby? Has anyone implemented LZW? Or,
Are there any open source applications that provide a set of features similar to

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.