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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:45:43+00:00 2026-06-14T16:45:43+00:00

Basically, I need to split the string like one quoted argument those are separate

  • 0

Basically, I need to split the string like

"one quoted argument" those are separate arguments "but not \"this one\""

to get in result the list of arguments

  • “one quoted argument”
  • those
  • are
  • separate
  • “but not \”this one\””

This regex "(\"|[^"])*"|[^ ]+ nearly does the job but the issue is that regular expression always (at least in java) tries to match the longest string possible.

In consequence, when I apply the regex to a string that starts and ends with a quoted arguments, it matches the whole string and does not create a group for each argument.

Is there a way to tweak this regex or the matcher or the pattern or whatever to handle that?

Note: don’t tell me I could use GetOpt or CommandLine.parse or anything else similar.
My concern is about pure java regex (if possible but I doubt it…).

  • 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-14T16:45:44+00:00Added an answer on June 14, 2026 at 4:45 pm

    You may use the non greedy qualifier *? to make it work:

    "(\\"|[^"])*?"|[^ ]+
    

    See this link for an example in action: http://gskinner.com/RegExr/?32srs

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

Sidebar

Related Questions

I need to parse a URL string like this one: &ad_eurl=http://www.youtube.com/video/4bL4FI1Gz6s&hl=it_IT&iv_logging_level=3&ad_flags=0&endscreen_module=http://s.ytimg.com/yt/swfbin/endscreen-vfl6o3XZn.swf&cid=241&cust_gender=1&avg_rating=4.82280613104 I need to
I have a string places=city,city,town. I need to get city,town. Basically get rid of
I basically need to get user input: gets.chomp(input?) And then to convert the given
I basically need to check if there is an easier way to do this
Basically I need to get older version of a file in the repository without
I have string value like this: string strRole = ab=Admin,ca=system,ou=application,role=branduk|ab=Manager,ca=system,ou=application,role=brankdusa|ab=sale,ca=system,ou=application,role=brandAu; I just need to
I basically need a function to check whether a string's characters (each character) is
ok, so i have this set of code if(message.toLowerCase().startsWith(!dl.exec)){ String[] args = message.split( );
Basically I have these connection strings that I need to split up, heres an
I need to split a string and extract words separated by whitespace characters.The source

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.