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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:48:57+00:00 2026-06-13T16:48:57+00:00

I want to write a function like that: – Input: 1 -> return :

  • 0

I want to write a function like that:

- Input: "1" -> return : "1"
- Input: "12" -> return : ["1","2"]

If I use the function split(): String.valueOf("12").split("") -> ["","1","2"]
But, I only want to get the result: ["1","2"].

What the best way to do this?

Infact, I can do that:

private List<String> decomposeQuantity(final int quantity) {
    LinkedList<String> list = new LinkedList<String>();
    int parsedQuantity = quantity;
    while (parsedQuantity > 0) {
        list.push(String.valueOf(parsedQuantity % 10));
        parsedQuantity = parsedQuantity / 10;
    }
    return list;
}

But, I want to use split() for having an affective code

  • 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-13T16:48:59+00:00Added an answer on June 13, 2026 at 4:48 pm
    String input = "123";
    String regex = "\\d";
    Matcher m = Pattern.compile(regex).matcher(input);
    
    String[] output = new String[input.length()];
    int index = 0;
    
    while (m.find())
        output[index++] = m.group();
    
    for (String s : output)
        System.out.println(s);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You want to write unittest -cases for a function like that: def test_me(a): for
I want to write a cmp -like function that compares two version numbers and
Say I want to write a function like this: int get_some_int(string index) { ...perform
I want to write a function like so, public System.Windows.Input.Key ResolveKey(char charToResolve) { //
I want to write a function that accepts any container holding strings. Something like
I want to write a Zsh function that looks like: smartwatch [WATCH_FILE] [COMMAND_TO_RUN] [COMMAND_ARGS]
I have a string that looks like this: -2.2,1.1-6.9,2.3-12.8,2.3 And I want to write
I want to write a general purpose utility function that will use an OpenGL
So basically I want to write a function that can be written like this:
I want to write a function like equalp, which gives #t for (equalp Xy

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.