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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:16:51+00:00 2026-05-22T22:16:51+00:00

I need some guidance on how to split a string with arithmetic operators and

  • 0

I need some guidance on how to split a string with arithmetic operators and functions in java
for the example String is:

"string1"+"String2" >= 10 * function1() / function2()

operators may be:

+ - * / ** / % / ( ) = != > < <= >=

After Split
I need the output like:

array[0]=string1
array[1]=string2
array[2]=10

I need only things inside the double quotes and contants or numbers, not a functions(function1()) or operators.

I need regular expression for this problem

  • 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-22T22:16:52+00:00Added an answer on May 22, 2026 at 10:16 pm

    If you need a regex for extracting things inside the double quotes and numbers, then you can use this java code:

    public static void main(String[] args) {
        Pattern p = Pattern.compile("\"(\\w+)\"|\\b\\d+\\b");
        Matcher m = p.matcher(
            "\"string1\"+\"String2\" >= 10 * function1() / function2()");
        List<String> parts = new ArrayList<String>();
        while (m.find()) {
            if (m.group(1) != null)
                parts.add(m.group(1));
            else
                parts.add(m.group(0));
        }
        System.out.println(Arrays.toString(parts.toArray(new String[] {})));        
    }
    

    which outputs:

    [string1, String2, 10]
    

    Note: I’m not sure that regex is the best tool in this case. As others suggested you may want to investigate the use of a parser.

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

Sidebar

Related Questions

Need some guidance. I have java webstart app and I want it to connect
i need some help and guidance in displaying the splitted Strings in order. let
Need some guidance on how to go about unit testing a shopping cart (.net
Need some guidance and ideally some first-hand experience. We committed to a php framework
Need some guidance figuring out what went wrong. I've been using mysql, phpmyadmin for
I need some guidance on how to save video data to core data so
I need some guidance with this issue I have. I have a navigational Controller,
I need some guidance on how to add a validation method to the jquery
I'm heavily geared towards C++ thinking and need some guidance on a specific C#
Possible Duplicate: I need some guidance on payment gateways hi, i have a web

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.