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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:15:17+00:00 2026-06-04T18:15:17+00:00

I have a quick question about Regex in Java (though other languages are probably

  • 0

I have a quick question about Regex in Java (though other languages are probably similar).

What I’m trying to do is to transform a String like this:

 How are you "Doing well" How well 10 "That's great"

//# I want the Regex in Java to match out all of the words, numbers, 
//# and things inside quotation marks. Ideally, I'd get something like this 

How
Are
You
"Doing Well"
How 
Well
10
"That's Great!"

The Regex I’m trying to use is the following:

String RegexPattern =   "[^"+           //  START_OR: start of line OR" 
                        "\\s" +         //  empty space OR
                        "(\\s*?<=\")]" + // ENDOR: preceeded by 0 or more spaces and a quotation mark 
                        "(\\w+)" +      // the actual word or number
                        "[\\s" +        // START_OR: followed by a space OR
                        "(?=\")" +      // followed by a quotation mark OR
                        "$]";           // ENDOF:  end of line

This Won’t work for me, though; even for much simpler strings! I’ve spent a lot of time looking for similar problems on here. If I didn’t need the quotations, I could just use a split; eventually, though, this pattern will get much more complicated, so I will need to use the Regex (this is just the first iteration).

I’d appreciate any help; thanks in advance!

  • 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-04T18:15:19+00:00Added an answer on June 4, 2026 at 6:15 pm

    I don’t think [ ] means what you think it means. Inside square brackets, ^ is actually a negation operator for the character class. You should practice with smaller regexes before embarking on this task. The pattern you’re looking for is more like:

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

    You can see this in action here: http://rubular.com/r/enq7eXg9Zm.

    If you don’t want symbols in words, then it’s probably best to use a second regex that removes them, e.g.

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

Sidebar

Related Questions

I have a quick question about Java synchronization. Please assume the following code: public
I have a quick question about Java synchronization. Please assume the following code: public
i just have a quick question about concurrent programming in Java. for example, i
I have a quick question about how smart the Java compiler provided in Sun's
A quick question about a gnuplot. I have two graphs, ploted from file, like
I have a quick question about encapsulating specific types with typedef . Say I
I have a quick question about the dealloc() and viewDidUnload() methods. I notice a
I have a quick question about the accelerometer in Android devices. Is it always
I have a quick question about the layout of the page on a custom
I have a quick question about altering the build path as the code is

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.