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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:39:56+00:00 2026-06-16T03:39:56+00:00

I have an example dynamic input of information like this: Xbox 360 (black) Elite

  • 0

I have an example dynamic input of information like this:

Xbox 360 (black) Elite Console 120GB (Mason City Illinois ) $200

$200 2013 North Trail Camper (RT 202. Manchester, Maine) $224/mo.

Snowmobile Bike trailers (Winthrop / Augusta) $40 Monthly

“Great Xmas Gift” XBox 360 Guitar Hero (Springfied)

I am trying to use Regex in Android to split the string into three parts:

  1. Text before XXX()
  2. Text in (XXX)
  3. Text after () XXX

Sometimes there won’t be a price, the text after the location in ().

I’ve tried to

Pattern p = Pattern.compile("\(([^]*)\)");
Matcher m = p.matcher(title);

But I can’t get matchers to work in Android. It always returns empty when I look in with matcher.group(1). I have it setup currently to look for either ( or $ and explode too give me the separate strings. But this is inaccurate and inefficient.

Any help is apperciated!

  • 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-16T03:39:57+00:00Added an answer on June 16, 2026 at 3:39 am

    I suspect you could do this with a regular expression, but it might be simpler not to.

        String input[] = {
                "Xbox 360 (black) Elite Console 120GB (Mason City Illinois ) $200",
                "$200 2013 North Trail Camper (RT 202. Manchester, Maine) $224/mo.",
                "Snowmobile Bike trailers (Winthrop / Augusta) $40 Monthly",
                "\"Great Xmas Gift\" XBox 360 Guitar Hero (Springfied)"
        };
        for (String s : input) {
            int lastClose = s.lastIndexOf(')');
            int lastOpen = s.lastIndexOf('(', lastClose);
            System.out.println(s.substring(0, lastOpen).trim() +
                    "~" + s.substring(lastOpen + 1, lastClose).trim() +
                    "~" + s.substring(lastClose + 1).trim());
        }
    

    prints

    Xbox 360 (black) Elite Console 120GB~Mason City Illinois~$200
    $200 2013 North Trail Camper~RT 202. Manchester, Maine~$224/mo.
    Snowmobile Bike trailers~Winthrop / Augusta~$40 Monthly
    "Great Xmas Gift" XBox 360 Guitar Hero~Springfied~
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic dialog I wish to raise... for example var newDiv =
I have to make dynamic hashes, so the class example won't work since the
I have basic hello word example of Prime Faces. I have created dynamic web
I have this example FactoryGirl.define do @site = FactoryGirl.create(:my_site) factory :user do email {
How can I create a dynamic form using jQuery. For example if I have
I have an object that has a dynamic number of attributes. For example a
I have an example project, a dynamic questionnaire system where any administrator can create
i have this example in jsfiddle of a accordion only made with css3, no
I have a gravity form on my site that looks like this: Activities: [checkbox]
I have example.org and foo.example.org pointing to the same directory, /var/www/html/ , and want

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.