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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:30:19+00:00 2026-06-15T13:30:19+00:00

What is the best way to do this? Let’s say I have a string

  • 0

What is the best way to do this?
Let’s say I have a string that is mixed with letters and numbers,

Srting str = "ha2iwea435";
String str2 = (str Digits);

and I want a string with just the numbers from in between the other letters, or at the end. So my other string would equal the 4th char of str, 2. I suppose I would need to put this in a for loop, and then append a List with the value of str2 so I could assign str2 to 435.
for example,

for(int i = 0; str.length() > i; i++){
    str2 = "";
    if(str(char_here(i).isNUMBER()) {
        for(y = i; str(char_here[y]).isNUMBER(); y++) {
          str2 += str.(char_here);
        }
    }
    List1.add(str2);
}

I have no idea what methods and tests to use.
So in the end, I would have a List that equals (“2”, “435”)

Thanks!

  • 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-15T13:30:22+00:00Added an answer on June 15, 2026 at 1:30 pm

    You can use a regex to remove the non-digits characters:

    String str = "ha2iwea435";
    String numbers = str.replaceAll("[^\\d]","");
    System.out.println("numbers = " + numbers); //prints 2435
    

    If you need each group of numbers in a list you can split on letters and add each group to a list:

    String str = "ha2iwea435";
    String[] numbers = str.split("[^\\d]");
    
    List<Integer> list = new ArrayList<> ();
    for (String number : numbers) {
        if (!number.isEmpty()) list.add(Integer.parseInt(number));
    }
    System.out.println("numbers = " + list); // numbers = [2, 435]
    

    And if you want to store the numbers as Strings:

    String str = "ha2iwea435";
    String[] numbers = str.split("[^\\d]");
    
    List<String> list = new ArrayList<> (Arrays.asList(numbers));
    list.removeAll(Arrays.asList(""));
    System.out.println("numbers = " + list); // numbers = [2, 435]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The best way to explain this is with examples. Let's say I have the
Ok so let me try to explain this the best way that i can.
I am struggling finding the best way to understand this: Let's say I am
The best way of describing this is I have a table of people with
I have a large list that looks essentially like this: let someList = [
Let's say I have something like this: def find_the_best(array) temp = 15435435435 # sufficiently
I am looking for the best way to implement, let's say a middle tier.
Let's say I have this div: <div> Let's say these are the words in
Is the best way to do this with Regex? I don't want it picking
What is the best way to solve this? A static member is one for

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.